
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2038 Articles for R Programming

2K+ Views
To sort a numerical factor column in an R data frame, we would need to column with as.character then as.numeric function and then order function will be used.For Example, if we have a data frame called df that contains a numerical factor column say F then we can use sort F by using the below mentioned command −df[order(as.numeric(as.character(df$F))),]Example 1Following snippet creates a sample data frame −Class

256 Views
To create a column of factorial values 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 factorial values 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

246 Views
To create a column of absolute values 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 absolute values 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

3K+ Views
To find the count of unique group combinations in an R data frame, we can use count function of dplyr package along with ungroup function.For Example, if we have a data frame called df that contains three grouping columns say G1, G2, and G3 then we can count the unique group combinations in df by using the below given command −count(df,G1,G2,G3)%%ungroup()Example 1Following snippet creates a sample data frame −Grp1

226 Views
To find the cumulative sums if some columns are categorical in R data frame, we can follow the below steps −First of all, create a data frame.Then, use numcolwise function from plyr package to find the cumulative sums if some columns are categorical.ExampleCreate the data frameLet’s create a data frame as shown below −Gender

2K+ Views
To multiply vector values in sequence with data frame columns in R, we can follow the below steps −First of all, create a data frame.Then, create a vector.After that, use t function for transpose and multiplication sign * to multiply vector values in sequence with data frame columns.Example 1Create the data frameLet’s create a data frame as shown below −x1

140 Views
To create a column of exponent 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 exponent 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

710 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

350 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

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[]