Search code examples
rfrequencycategorical-data

frequency counts with categorical variables


I have two categorical variables.

Variable A has about 15 levels and Variable B is dummy coded (0,1)

I am looking to get a table with the frequency counts of 1's in Variable B for each of the 15 levels of Variable A.


Solution

  • We can use table from base R after subsetting the columns of interest

    table(df1[c('A', 'B')])