R Subset Data Frame by Column

R subset() function returns the subset of the data frame which meets the condition. Subsetting data frame in R extracts the variables and observations from the data frame which meets the specified condition. subset() function accepts three parameters as data frame to be subsetted, logical expression to keep row or …

Read more

Combine Two Vectors in R

cbind() function and data.frame() function in the base R package is used to combine two vectors in R. Vectors in R hold the multiple values of the same data type. Functions take vectors as input parameters and combine two vectors to data frame or matrix in R. cbind() function of …

Read more

Mean of Columns in Data Frame in R

mean() function and colMeans() function of the R base package is used to get the mean of columns in the data frame. It accepts the data frame as input argument and column name to find the mean of the column in R. The function calculates the mean of a column …

Read more

Select Rows by Condition in R

Using the subset() function in R, we can select rows by conditions specified in the square bracket notation for the data frame. We can specify the logical condition with operators to select rows by the condition in R. The Subsetting data frame returns a subset of the data frame which …

Read more

Convert Data Frame to Data Table in R

Using the data.table package setDT function in R, we can convert data frame to a data table. The data.table package in R provides an enhanced version of a data frame. setDT() function converts the data frame to the data table. setDT() syntax: In this tutorial, we will discuss how to …

Read more

Reorder Columns of Data Frame in R

Reorder columns of a data frame in R is quite important when you want to deal with large data set and have large columns. Reordering columns of a data frame is helpful to keep important and useful columns at the beginning for data analysis. Using the select() function in R …

Read more

Remove First Row of Data Frame in R

Using the negative indexing into the data frame, we can remove the first row of a data frame in R. Syntax to remove the first row of the data frame In this tutorial, we will discuss how to remove the first row of a data frame in R using negative …

Read more

Get R Data Frame Row Names

All the data frames have row names. Using the row.names() or row.names.data.frame() function in R, we can get the data frame row names. row.names() or row.names.data.frame() function gets the character vectors of the length of the rows in the data frame. In this tutorial, we will discuss about how to …

Read more