How to subset a certain column
data.frame$variable.name
or
data.frame[ , # of the column]
or
data.frame[ , "variable.name"]
All three options above are the same, we are choosing a certain column. For example, if we have a data frame survey which consists of 1,000 observations, and each observation is described by 3 variables: gender, age, and marital status, by using survey$age we can subset the column named “age” for all 1,000 observations.