Create Scatterplot with Two Legends Using ggplot2 in R

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:25:37

1K+ Views

If we want to create a scatterplot with two legends then we must be having two categorical or factor columns. This can be done by using the below steps −Creating a data frame with two numerical and two categorical columnsCreating the scatterplot with shape and color argument of geom_point function of ggplot2 packageCreate the data frameLet's create a data frame as shown below − Live Demox

Subset Data Frame by Excluding a Column using dplyr in R

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:24:27

562 Views

Subsetting is one of the commonly used technique which serves many different purposes depending on the objective of analysis. To subset a data frame by excluding a column with the help of dplyr package, we can follow the below steps −Creating a data frame.Subsetting the data frame by excluding a column with select function of dplyr package.Create the data frameLet's create a data frame as shown below − Live Demox1

Subset Rows of an R Data Frame by Column Values

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:23:13

959 Views

To subset rows of an R data frame if any columns have values greater than a certain value, we can follow the below steps −First of all, create a data frame.Then, use filter_all function of dplyr package with any_vars function to subset the rows of the data frame for any columns having values greater than a certain value.Create the data frameLet's create a data frame as shown below − Live Demox1

Divide Data Frame Rows in R by Row Minimum

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:22:22

267 Views

To divide the data frame row values by row minimum in R, we can follow the below steps −First of all, create a data frame.Then, use apply function to divide the data frame row values by row minimum.Create the data frameLet's create a data frame as shown below − Live Demox

Subset Rows of Data Frame Without NA Using dplyr in R

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:20:47

615 Views

To subset rows of data frame without NA using dplyr in R, we can follow the below steps −First of all, create a data frame.Then, use filter function of dplyr package to subset the rows with !is.na.Create the data frameLet's create a data frame as shown below − Live Demox

Subset Row Values Based on Column Names in R Data Frame

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:19:50

549 Views

To subset row values based on columns name in R data frame, we can follow the below steps −First of all, create a data frame.Then, create a sample of column names of size equal to number of rows in the data frame and row names in the same manner with seq_len function, after that use cbind function to subset the rows based on columns name.Create the data frameLet's create a data frame as shown below − Live DemoGender_1

Point Estimate Using Regression Model in R

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:18:10

3K+ Views

To find the point estimate using regression model in R, we can follow the below steps −First of all, create a data frame.Then, create the regression model.After that, define the value for which we want to find the point estimate and use predict function to find the estimate.Create the data frameLet's create a data frame as shown below − Live Demox1

Find Column Mean of First N Rows in R Data Frame

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:17:00

857 Views

To find the column mean of first n number of rows in R data frame, we can follow the below steps −First of all, create a data frame.Then, use colMeans function by reading the data frame with matrix function and nrow argument.Example1Create the data frameLet's create a data frame as shown below − Live Demox

Replace Matrix Values Using If-Else in R

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:15:36

1K+ Views

To replace matrix values using ifelse in R, we can follow the below steps −First of all, create a matrix.Then, use ifelse function to replace the values in the matrix.Create the matrixLet’s create a matrix as shown below − Live DemoM

Create Scatterplot Between Variable and Equation in R

Nizamuddin Siddiqui
Updated on 13-Aug-2021 11:14:41

121 Views

To create a scatterplot between a variable and an equation in R, we can follow the below steps −First of all, create a vectorThen, create the equation and store it in an object.After that, use plot function to create the plot between vector and equation objectCreate the vectorLet’s create a vector as shown below − Live Demox

Advertisements