I\'m trying to quickly replace multiple characters in a string with another character such as *
*
For example, I have a string such as:
string
in base R, besides the method of substring() and for-loop shown by @akrun,, you can use utf8ToInt() and intToUtf8 to make it
base R
substring()
for-loop
utf8ToInt()
intToUtf8
v <- utf8ToInt(string) v[string_indexes_replaced ] <- utf8ToInt("*") res <- intToUtf8(v)
which gives
> res [1] "*bc*e*gh*j"