Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 126 of 196

How to display legend in base R with different colors?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 2K+ Views

To display legend in base R with different colors, we can follow the below steps −First of all, create a plot using plot function.Then, use legend function legend argument and col argument to display legend with different colors.ExampleCreate the plotLet’s create a plot of a vector x using plot function −x

Read More

How to find the mean of a column summarized by other column names and common values in those columns in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 150 Views

To find the mean of a column summarized by other column names and common values in those columns in R data frame, we can follow the below steps −First of all, create a data frame.Then, melt the data frame using melt function from reshape2 package.After that, use dcast function to find the mean of a column summarized by other column names and common values in those columns.ExampleCreate the data frameLet’s create a data frame as shown below −S.No

Read More

How to decompose a time series with trend and seasonal components using loess method in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 523 Views

To decompose a time series with trend and seasonal components using loess method in R, we can follow the below steps −First of all, create a time series object.Then, use stl function to decompose the time series with trend and seasonal components.ExampleCreate the time series objectLet’s create a time series object using ts function −x

Read More

How to display text in bar plot in the middle using ggplot2 in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 4K+ Views

To display text in bar plot in the middle using ggplot2 in R, we can follow the below steps −First of all, create a data frame.Then, use ggplot function and geom_bar function to create the bar plot along with geom_text function to display the text in the middleExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to plot matrix elements using corrplot in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 3K+ Views

To create a plot of matrix elements with the help of corrplot function, we would need to set is.corr argument to FALSE so that the matrix values will be plotted in the diagram, otherwise, the corrplot function requires correlation matrix instead of a matrix hence there will be an error as shown in the Example below.ExampleConsider the matrix given below −M

Read More

How to draw concentric circles in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 862 Views

To draw concentric circles, we can use draw.circle function of plotrix package but firstly, we would need to create a blank graph with plot function as shown below.For Example, we can create three concentric circles at position X=5 and Y=5 having radius of 1, 2, and 3 by using the below command −draw.circle(5, 5, c(3, 2, 1), col=c("blue", "red", "green"))ExampleTo create three concentric circles at position X=5 and Y=5 having radius of 1, 2, and 3 add the following code to the above snippet −plot(1:10, type="n")OutputIf you execute all the above given snippets as a single program, it generates the ...

Read More

How to convert values greater than a threshold into 1 in R data frame column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 3K+ Views

To convert values greater than a threshold into 1 in R data frame column, we can follow the below steps −First of all, create a data frame.Then, use ifelse function to convert values greater than a threshold into 1.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to subset R data frame rows if at least one or more values matches?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 482 Views

To subset R data frame rows if at least one or more values matches, we can follow the below steps −First of all, create a data frame.Then, use rowSums function along with sapply function and values for match to subset the data frame rows if at least one or more values matches.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to repeat column values in R data frame by values in another column?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 3K+ Views

To repeat column values in R data frame by values in another column, we can follow the below steps −First of all, create a data frame.Then, use rep function along with cbind function to repeat column values in the matrix by values in another column.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

How to standardize selected columns in R data frame?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 11-Nov-2021 3K+ Views

To standardize selected columns in R data frame, we can follow the below steps −First of all, create a data frame.Then, use scale function with subsetting to standardize selected columns.ExampleCreate the data frameLet’s create a data frame as shown below −v1

Read More
Showing 1251–1260 of 1,958 articles
« Prev 1 124 125 126 127 128 196 Next »
Advertisements