更新时间:2023-02-12 18:57:30
in base R
, besides the method of substring()
and for-loop
shown by @akrun,, you can use utf8ToInt()
and intToUtf8
to make it
v <- utf8ToInt(string)
v[string_indexes_replaced ] <- utf8ToInt("*")
res <- intToUtf8(v)
给出
> res
[1] "*bc*e*gh*j"