sub_str start end参数为向量的计算过程?

str_sub(string, start = 1L, end = -1L)
str_sub(string, start = 1L, end = -1L, omit_na = FALSE) <- value

library(stringr)
z<- "zhang"
str_sub(z,1,5)
## [1] "zhang"
str_sub(z,seq_len(str_length(z)))
## [1] "zhang" "hang"  "ang"   "ng"    "g"
str_sub(z,seq_len(5))
## [1] "zhang" "hang"  "ang"   "ng"    "g"
str_sub(z,1:5)
## [1] "zhang" "hang"  "ang"   "ng"    "g"
str_sub(z,c(1,2,3,4,5))
## [1] "zhang" "hang"  "ang"   "ng"    "g"
str_sub("zhang",seq(1:5))
## [1] "zhang" "hang"  "ang"   "ng"    "g"
> str_sub("zhang",1,2,3,4,5)
Error in str_sub("zhang", 1, 2, 3, 4, 5) : unused arguments (3, 4, 5)

你可能感兴趣的:(sub_str start end参数为向量的计算过程?)