Show Menu
Cheatography

R dataframe Cheat Sheet (DRAFT) by

Routine utilities in modifying R dataframe.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Modifying rows and columns in a dataframe

Selecting 1,2,4,5 columns from a dataframe
df <- subset(x = df,select = c(1,2,­4,5))
Subsetting specific values from a dataframe using equation
df <- subset(x = df, subset = df$gen­der­==c­("ma­le",­"­fem­ale­"))
Subsetting specific values from a dataframe using negation
df <- subset(x = df, subset = df$gen­der­!=c­("un­kno­wn"))

Access specific elements of a dataframe

Access column of dataframe
By single square bracket
df["­col­"]
 
By double square bracket
df[["co­l"]]
 
By dollar sign
df$col