I have a dataset containing 100000 rows of data. I tried to do some countif operations in Excel, but it was prohibitively slow. So I am wondering if this kind o
Given a dataset
df <- data.frame( sex = c('M', 'M', 'F', 'F', 'M'),
occupation = c('analyst', 'dentist', 'dentist', 'analyst', 'cook') )
you can subset rows
df[df$sex == 'M',] # To get all males
df[df$occupation == 'analyst',] # All analysts
etc.
If you want to get number of rows, just call the function nrow such as
nrow(df[df$sex == 'M',])