Nizamuddin Siddiqui

Nizamuddin Siddiqui

1,958 Articles Published

Articles by Nizamuddin Siddiqui

Page 134 of 196

How to create a column of log with base 10 in data frames stored in R list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 10-Nov-2021 787 Views

To create a column of log with base 10 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 log with base 10 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

Read More

How to combine matrix rows alternately in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 408 Views

If we have multiple matrices and we want to combine the rows of those matrices alternately then we would first need to find the order of the matrices with order function along with sequence and sapply function after reading the matrices with list after that the values will be combined with rbind function.Check out the Example given below to understand how it can be done.ExampleFollowing snippet creates a sample matrix −M1

Read More

Replace all values in an R data frame if they are greater than a certain value.

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

To replace all values in an R data frame if they are greater than a certain value, we can use apply function with ifelse function.For Example, if we have a data frame called df and we want to replace all values in df with 5 if they are greater than 10 then we can use the command given below −df[]

Read More

How to deal with hist.default, 'x' must be numeric in R?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 9K+ Views

The error hist.default, 'x' must be numeric occurs when we pass a non-numerical column or vector to the hist function. If we have a non-numerical column in a data frame or a non-numerical vector and we want to create the histogram of that data can be created with the help of barplot and table function.Check out the below given Exampleto understand how it can be done.ExampleFollowing snippet creates a sample data frame −x

Read More

Create a data frame with numerical as well as factor columns in R.

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

To create a data frame with numerical as well as factor columns in R, we simply need to add factor function before factor columns and numerical columns will be created without mentioning any specific characteristics, the values of numerical columns just need to be numerical in nature.Example 1Following snippet creates a sample data frame df1 with factor and numerical column −Gender

Read More

How to create a column of log with base 2 in data frames stored in R list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 272 Views

To create a column of log with base 2 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 log with base 2 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

Read More

How to create a column of square in data frames stored in R list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 240 Views

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

Read More

Replace numerical column values based on character column values in R data frame.

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

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

Read More

How to split a data frame by column in R?

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

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

Read More

How to create a column of division in data frames stored in R list?

Nizamuddin Siddiqui
Nizamuddin Siddiqui
Updated on 09-Nov-2021 186 Views

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

Read More
Showing 1331–1340 of 1,958 articles
« Prev 1 132 133 134 135 136 196 Next »
Advertisements