R table()

1 개요[ | ]

R table()

2 벡터[ | ]

R
Copy
x <- c(3,1,4,1,5,2,6,5)
table(x)
Loading
R
Copy
table( c(3,1,4,1,5,2,6,5) )
Loading
R
Copy
table( c("a","b","b","c","c","c","d") )
Loading

3 데이터프레임 컬럼[ | ]

R
Reload
Copy
table(iris$Species)
Loading
Copy
v <- c(1, 'hello', 1, 'world', 'hello')
table(v)
Loading
Copy
summary(warpbreaks)
Loading
Copy
table(warpbreaks$wool,warpbreaks$tension)
Loading
Copy
scores <- read.table( header=TRUE, stringsAsFactors=FALSE, text="
Class  Name variable value
    A Alice  English    90
    A   Bob  English    80
    B  Dave  English    60
    A Alice     Math    60
    B Carol     Math    80
    B  Dave     Math    90
")
table( scores$variable )
Loading
Copy
table( scores$value )
Loading

4 table()과 ddply()[ | ]

R
Reload
Copy
library(plyr)
table(baseball[1:100,]$year)
Loading
Copy
ddply(baseball[1:100,], ~year, nrow)
Loading
Copy
ddply(baseball[1:100,], 'year', nrow)
Loading
Copy
ddply(baseball[1:100,], .(year), nrow)
Loading

5 같이 보기[ | ]

6 참고[ | ]