R : Extracting Numeric and Factor Variables


R Data Science: R Programming A-Z: R For Data Science With Real Exercises!

In R, you can extract numeric and factor variables using sapply function.

Extracting Numeric Variables
# Extracting Numeric Variables
cols <- sapply(mydata, is.numeric)
abc = mydata [,cols]
Note : mydata is a dataframe

Extracting Factor Variables
# Extracting Numeric Variables
cols <- sapply(mydata, is.factor)
abc = mydata [,cols]
Note : mydata is a dataframe
Coursera Data Science

R Tutorials : 75 Free R Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

0 Response to "R : Extracting Numeric and Factor Variables"

Post a Comment

Next → ← Prev