【描述】
Extract or replace substrings in a character vector.
提取或取代字符串中的子字符串
【用法】
substr(x, start, stop)
substring(text, first, last = 1000000L)
substr(x, start, stop) <- value
substring(text, first, last = 1000000L) <- value
【参数】
x, text
a character vector.
start, first
integer. The first element to be replaced.
stop, last
integer. The last element to be replaced.
value
a character vector, recycled if necessary.
【代码】
> substr(month.name, 1, 3)
[1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
> paste(substr(month.name, 1, 3), '.', sep = '')
[1] "Jan." "Feb." "Mar." "Apr." "May." "Jun." "Jul." "Aug." "Sep." "Oct." "Nov." "Dec."
网友评论