How to subset data in R

How to subset a certain column



data.frame[ , # of the column]


data.frame[ , ""]

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.

Continue reading ‘How to subset data in R’ »