R table()

Jmnote (토론 | 기여)님의 2019년 5월 11일 (토) 19:27 판 (→‎같이 보기)

1 개요

R table()
벡터
x <- c(3,1,4,1,5,2,6,5)
table(x)
## x
## 1 2 3 4 5 6 
## 2 1 1 1 2 1
table( c(3,1,4,1,5,2,6,5) )
## 
## 1 2 3 4 5 6 
## 2 1 1 1 2 1
데이터프레임$컬럼
v <- c(1, 'hello', 1, 'world', 'hello')
table(v)
## v
##     1 hello world 
##     2     2     1
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
")
scores
##   Class  Name variable value
## 1     A Alice  English    90
## 2     A   Bob  English    80
## 3     B  Dave  English    60
## 4     A Alice     Math    60
## 5     B Carol     Math    80
## 6     B  Dave     Math    90

table( scores$variable )
## English    Math 
##       3       3 

table( scores$value )
## 60 80 90 
##  2  2  2

2 같이 보기

3 참고

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