R table()

Jmnote (토론 | 기여)님의 2021년 5월 21일 (금) 23:09 판 (→‎개요)

1 개요

R table()
벡터
x <- c(3,1,4,1,5,2,6,5)
table(x)
table( c(3,1,4,1,5,2,6,5) )
table( c("a","b","b","c","c","c","d") )
데이터프레임$컬럼
table(iris$Species)
v <- c(1, 'hello', 1, 'world', 'hello')
table(v)
options(echo=T)
summary(warpbreaks)
table(warpbreaks$wool,warpbreaks$tension)
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
")
options(echo=T)
table( scores$variable )
table( scores$value )
table()과 ddply()
options(echo=T)
library(plyr)
table(baseball[1:100,]$year)
ddply(baseball[1:100,], ~year, nrow)
ddply(baseball[1:100,], 'year', nrow)
ddply(baseball[1:100,], .(year), nrow)

2 같이 보기

3 참고

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}