R에서 문자열 추출
1. substring
2. 예제
3. 그 박의 문자열 조작 substr, str_sub
4. stringr cheat sheet
1. substring()
substr(text, start, stop)
substring(text, first, last = 1000000L)
2. 예제
extracting
substring("HumptyDumpty sat on a wall",5,9)
replacing
mystring<-"Humpty_Dumpty sat on a wall"
substring(mystring,7,7)=" "
mystring
3. 그 박의 문자열 조작
substr
df1$substring_State = substr(df1$State,1,4)
df1
str_sub
library(stringr)
df1$substring_State = str_sub(df1$State,1,4)
df1
4. stringr cheat sheet
ref :
https://stringr.tidyverse.org/
https://github.com/rstudio/cheatsheets/blob/main/strings.pdf
https://www.datasciencemadesimple.com/substring-function-in-r/