table() counts the different factor levels
> library(MASS)
> school <- painters$School
> painters
Composition Drawing Colour Expression School
Da Udine 10 8 16 3 A
Da Vinci 15 16 4 14 A
Del Piombo 8 13 16 7 A
Del Sarto 12 16 9 8 A
Fr. Penni 0 15 8 0 A
Guilio Romano 15 16 4 14 A
Michelangelo 8 17 4 8 A
Perino del Vaga 15 16 7 6 A
......
Loading test data set.
> school.freq <- table(school)
> school.freq
school
A B C D E F G H
10 6 6 10 7 4 7 4
cbind() function takes a sequence of vector, matrix or data.frame and combine columns and rows respectively.
> cbind(school.freq)
school.freq
A 10
B 6
C 6
D 10
E 7
F 4
G 7
H 4