R paste()

Jmnote (토론 | 기여)님의 2019년 4월 19일 (금) 01:47 판
  다른 뜻에 대해서는 paste 문서를 참조하십시오.
  다른 뜻에 대해서는 리눅스 paste 문서를 참조하십시오.

1 개요

R paste()
paste("hello", "world", "lorem", "ipsum")
##  [1] "hello world lorem ipsum"

paste(1:12)
##  [1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12"
paste("A", "B", "C", "D", sep = " - ")
## [1] "A - B - C - D"
paste("A", "B", "C", "D", collapse = " - ")
## [1] "A B C D"
paste(c("A", "B", "C", "D"), collapse = " - ")
## [1] "A - B - C - D"
nth <- paste0(1:8, c("st", "nd", "rd", rep("th", 5)))
nth
## [1] "1st" "2nd" "3rd" "4th" "5th" "6th" "7th" "8th"
myletter <- toupper(letters[1:4])
myletter
## [1] "A" "B" "C" "D"
paste(myletter, "is the", nth, "letter.")
## [1] "A is the 1st letter." "B is the 2nd letter." "C is the 3rd letter."
## [4] "D is the 4th letter." "A is the 5th letter." "B is the 6th letter."
## [7] "C is the 7th letter." "D is the 8th letter."
paste(myletter, "is the", nth, "letter.", sep ="__")
## [1] "A__is the__1st__letter." "B__is the__2nd__letter."
## [3] "C__is the__3rd__letter." "D__is the__4th__letter."
## [5] "A__is the__5th__letter." "B__is the__6th__letter."
## [7] "C__is the__7th__letter." "D__is the__8th__letter."

2 같이 보기

3 참고

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