Search
 
SCRIPT & CODE EXAMPLE
 

R

r dataframe column factor

mtcars  #look at this built in data set
str(mtcars) #allows you to see the classes of the variables (all numeric)

#one approach it to index with the $ sign and the as.factor function
mtcars$am <- as.factor(mtcars$am)
#another approach
mtcars[, 'cyl'] <- as.factor(mtcars[, 'cyl'])
str(mtcars)  # now look at the classes
Comment

PREVIOUS NEXT
Code Example
R :: how to select certain rows containing a word in r 
R :: data table R select several columns 
R :: set row names in r 
R :: descending order a list in r 
R :: how to split a column in r 
R :: comment in r 
R :: How to Convert a Factor in R 
R :: ggplot2 multiple lines geom_line 
R :: if not NA in r 
R :: r ddply 
R :: show 2 plots together 
R :: describe data in r 
R :: subset row r 
R :: how to replace values with na in r 
R :: Derive end of the week date in r 
R :: change labels in legend R 
R :: how to source all fies from a directory in r 
R :: extract attribute in r 
R :: logical vector passed in R 
R :: return the name of the dataset in r 
R :: required in r 
R :: store list in data.frame R 
R :: Non-redundant version of expand.grid 
R :: how to get the number of individual numbers in a vector in r 
Rust :: array as a parameter rust 
Rust :: rust get crate version 
Rust :: rust struct 
Rust :: rust init vec with values 
Rust :: armanriazi•rust•borrowchecker•lifetime•static 
Rust :: armanriazi•rust•orphan•rule 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =