"R substr()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;R substr()
;R substr()
* "Substrings Of A Character Vector {{해석|캐릭터 벡터의 부분문자열}}"
* 캐릭터 벡터에서 부분문자열을 추출하거나 교체한다.


<source lang='r' run>
<syntaxhighlight lang='r' run>
substr("ABCDEF", 3, 3) ## [1] "C"
substr("ABCDEF", 3, 3) ## [1] "C"
substr("ABCDEF", 3, 5) ## [1] "CDE"
substr("ABCDEF", 3, 5) ## [1] "CDE"
</source>
</syntaxhighlight>
<source lang='r' run>
<syntaxhighlight lang='r' run>
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 1)  ## [1] "A" "a" "1" "Q"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 1)  ## [1] "A" "a" "1" "Q"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 3)  ## [1] "ABC" "abc" "123" "QWE"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 3)  ## [1] "ABC" "abc" "123" "QWE"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 2:3) ## [1] "AB"  "abc" "12"  "QWE"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 2:3) ## [1] "AB"  "abc" "12"  "QWE"
</source>
</syntaxhighlight>
<source lang='r' run>
<syntaxhighlight lang='r' run>
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:2, 4)  ## [1] "ABCD" "bcd"  "1234" "WER"  
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:2, 4)  ## [1] "ABCD" "bcd"  "1234" "WER"  
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:4, 4)  ## [1] "ABCD" "bcd"  "34"  "R"   
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:4, 4)  ## [1] "ABCD" "bcd"  "34"  "R"   
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:4, 4:7) ## [1] "ABCD" "bcde" "3456" "RTYU"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:4, 4:7) ## [1] "ABCD" "bcde" "3456" "RTYU"
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
27번째 줄: 29번째 줄:


[[분류: R base]]
[[분류: R base]]
[[분류: R 문자열]]

2020년 11월 15일 (일) 01:10 기준 최신판

1 개요[ | ]

R substr()
  • "Substrings Of A Character Vector → 캐릭터 벡터의 부분문자열"
  • 캐릭터 벡터에서 부분문자열을 추출하거나 교체한다.
substr("ABCDEF", 3, 3) ## [1] "C"
substr("ABCDEF", 3, 5) ## [1] "CDE"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 1)   ## [1] "A" "a" "1" "Q"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 3)   ## [1] "ABC" "abc" "123" "QWE"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1, 2:3) ## [1] "AB"  "abc" "12"  "QWE"
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:2, 4)   ## [1] "ABCD" "bcd"  "1234" "WER" 
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:4, 4)   ## [1] "ABCD" "bcd"  "34"   "R"   
substr(c("ABCDEFGH","abcdefgh","12345678","QWERTYUI"), 1:4, 4:7) ## [1] "ABCD" "bcde" "3456" "RTYU"

2 같이 보기[ | ]

3 참고[ | ]

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