To create a column of natural log in data frames stored in R list, we can follow the below steps −First of all, create a list of data frames.Then, use lapply function to create a column of natural log in data frames stored in the list.ExampleCreate the list of data framesUsing data.frame function to create data frames and list function to create the list of those data frames −df1
To create a column of raise to the power 3 in data frames stored in R list, we can follow the below steps −First of all, create a list of data frames.Then, use lapply function to create a column of raise to the power 3 in data frames stored in the list.ExampleCreate the list of data framesUsing data.frame function to create data frames and list function to create the list of those data frames −df1
To randomize rows of a matrix in R, we can use sample function along with nrow function to get the random rows and then subset the matrix with single square brackets.For example, if we have a matrix called M then randomization of rows in M can be done by using the command given below − Random_rows
To create a column of square root in data frames stored in R list, we can follow the below steps −First of all, create a list of data frames.Then, use lapply function to create a column of square root in data frames stored in the list.ExampleCreate the list of data framesUsing data.frame function to create data frames and list function to create the list of those data frames −df1
To create a column of square in data frames stored in R list, we can follow the below steps −First of all, create a list of data frames.Then, use lapply function to create a column of square in data frames stored in the list.ExampleCreate the list of data framesUsing data.frame function to create data frames and list function to create the list of those data frames −df1
To replace numerical column values based on character column values in R data frame, we can use subsetting with single square brackets and %in% operator and the value will be assigned with
If we have a data frame column that contains some duplicate values or represent categories then we might want to split the data frame based on that column.For example, if we have a data frame called df that contains a column say Col then we can split the data frame by Col by using the command given below −split(df,df$Col)Example 1Following snippet creates a sample data frame −Group
To create a column of division in data frames stored in R list, we can follow the below steps −First of all, create a list of data frames.Then, use lapply function to create a column of division in data frames stored in the list.ExampleCreate the list of data framesUsing data.frame function to create data frames and list function to create the list of those data frames −df1
To write text outside plot using ggplot2, we can use annotate function and coord_cartesian function. The annotate function will define the text value and the coord_cartesian function will define the position of the text outside the plot area.Check out the below example to understand how it works.ExampleFollowing snippet creates a sample data frame −x
To find the mean of multiple columns based on multiple grouping columns in R data frame, we can use summarise_at function with mean function.For Example, if we have a data frame called df that contains two grouping columns say G1 and G2 and two numerical columns say Num1 and Num2 then we can find the mean of Num1 and Num2 based on G1 and G2 by using the below mentioned command −df%%group_by(G1,G2)%%summarise_at(vars("Num1","Num2"),mean)Example 1Following snippet creates a sample data frame −Gender
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP