您的位置:首页 > 其它

R table()&cbind() Fuction

2015-10-31 03:38 232 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: