Nizamuddin Siddiqui has Published 2307 Articles

How to multiply corresponding values from two data frames in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 05:46:06

1K+ Views

To multiply corresponding values from two data frames in R, we can follow the below steps −First of all, create two data frames.Then, use mapply function to multiply corresponding values from those two data frames.ExampleCreate the first data frameLet’s create a data frame as shown below −df1Read More

How to subset a matrix in R by ignoring a value in one of the columns?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 05:43:23

177 Views

To subset a matrix in R by ignoring a value in one of the columns, we can follow the below steps −First of all, create a matrix.Then, use single square brackets to subset the matrix by ignoring a value in one of the columns.ExampleCreate the matrixLet’s create a matrix as ... Read More

How to create a column of first non-zero value in each row of an R data frame?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 05:35:13

523 Views

To create a column of first non-zero value in each row of an R data frame, we can follow the below steps −First of all, create a data frame with some zero values.Then, use apply function and a custom function to find the first non-zero in each row of the ... Read More

How to unsplit a split data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 05:33:26

209 Views

To unsplit a split data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, use split function to split the data.table object.After that, use do.call function along with rbind function unsplit the data frame.ExampleCreate the data.table objectLet’s create a data.table object as shown ... Read More

How to standardize multiple columns not all in data.table object in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 05:27:52

188 Views

To standardize multiple columns not all in data.table object in R, we can follow the below steps −First of all, create a data.table object.Then, subset the columns with single square brackets and use lapply, list and scale function to standardize those columns.ExampleCreate the data.table objectLet’s create a data.table object as ... Read More

Create ggplot2 graph with reversed Y-axis and X-axis on top in R.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 04:08:58

903 Views

To create ggplot2 graph with reversed Y-axis and X-axis on top, we can use scale_y_reverse and scale_x_continuous function of ggplot2 package.For Example, if we have a data frame called df that contains two columns say X and Y and we want to create the scatterplot between X and Y with ... Read More

How to create correlation matrix plot without variables labels in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 04:06:03

365 Views

To create correlation matrix plot without variables labels in R, we can use tl.pos argument set to n.For Example, if we have a correlation matrix say M then we can create the correlation matrix plot without variables labels by using the below command −corrplot(M, tl.pos='n')ExampleFollowing snippet creates a sample data ... Read More

How to create bar plot with gradient colors using ggplot2 in R?

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 04:01:29

4K+ Views

To create bar plot with gradient colors using ggplot2, we can use scale_fill_gradient function where we can set the lower and higher color values.For Example, if we have a data frame called df that contains two columns say Cat and Count then we can create the bar plot with gradient ... Read More

Create ggplot2 graph with darker axes labels, lines and titles in R

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 04:00:20

540 Views

To create a ggplot2 graph with darker axes labels, darker lines, and dark titles, we can use theme_classic function of ggplot2 package with base_size argument set to a larger value.For Example, if we have a data frame called df that contains two columns say x and y then we can ... Read More

Create multiple regression lines in a single plot using ggplot2 in R.

Nizamuddin Siddiqui

Nizamuddin Siddiqui

Updated on 12-Nov-2021 03:52:33

9K+ Views

To create multiple regression lines in a single plot using ggplot2, we can use geom_jitter function along with geom_smooth function. The geom_smooth function will help us to different regression line with different colors and geom_jitter will differentiate the points.Check out the below Example to understand how it can be done.ExampleFollowing ... Read More

Advertisements