I can get the levels and frequencies of a categorical variable using table() function. But I need to feed the most frequent level into calculations later. How c
table()
ll<-data.frame(table(a)) ll[which.max(ll$Freq),]
Example from mtcars data:
ll<-data.frame(table(mtcars$cyl)) ll Var1 Freq 1 4 11 2 6 7 3 8 14 ll[which.max(ll$Freq),] Var1 Freq 3 8 14