R 벡터 정수 인덱스로 원소 선택

1 개요[ | ]

Numeric Index Vector
Using integer vector as index
R 벡터 정수 인덱스로 원소 선택
x <- letters[1:10]
x
##  [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"

x[1]
## [1] "a"
x[3]
## [1] "c"

x[3:5]
## [1] "c" "d" "e"
x[c(3,6,7)]
## [1] "c" "f" "g"

x[0]
## character(0)
x[-1]
## [1] "b" "c" "d" "e" "f" "g" "h" "i" "j"
x[-2]
## [1] "a" "c" "d" "e" "f" "g" "h" "i" "j"

x[c(-2:-8)]
## [1] "a" "i" "j"
x[-c(2:8)]
## [1] "a" "i" "j"

2 같이 보기[ | ]

3 참고[ | ]

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