Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 13 of 196

How to create a data frame column with equally spaced values between 0 and 1 in R?

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

To create a data frame column with equally spaced values between 0 and 1, we can use ppoints function. For example, if we want to create a data frame df with hundred equally spaced values between 0 and 1 then we can use the below mentioned command −df

Read More

How to save the str output as a string in R?

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

To save the str output as a string in R, we can use capture.output function along with str function.For example, if we have a data frame called df and we want to store the str output of df as a string then we can use the command given below −capture.output(str(df))It would be better if we save it in an object as str_df

Read More

How to find the moving standard deviation in an R data frame?

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

To find the moving standard deviation in an R data frame, we can make use of rollapply function of zoo package.For example, if we have a data frame called df and we want to find the 2 moving standard deviations then we can use the below given command −rollapply(df,width=2,FUN=sd,fill=0,align="r")Example 1Following snippet creates a sample data frame −x1

Read More

How to change the background color of base R plot region?

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

To change the background color of base R plot region, we can follow the below steps −First of all, create a plot in base R to understand the difference.Then, use par function with bg argument where you can put color name and then create the same plot.ExampleCreate the plotLet’s create a barplot in base R as shown below −x

Read More

How to remove rows in R data frame that contains a specific number?

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

To remove rows in R data frame that contains a specific number, we can follow the below steps −First of all, create a data frame.Then, use single square subsetting with apply function to remove rows that contains a specific number.ExampleCreate the data frameLet’s create a data frame as shown below −x

Read More

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 131 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 511 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
Showing 121–130 of 1,958 articles
« Prev 1 11 12 13 14 15 196 Next »
Advertisements