Displaying 1 result from an estimated 1 matches for "ijusttoldyou".
2012 Feb 08
4
String position character replacement
Hi,
Is there a way to efficiently replace specified indices in a string with another character? For example, if I had a vector of strings such as
[1] "hellohowareyoudoing"
[2] "imgoodhowareyou"
[3] "goodandyou"
[4] "yesimgoodijusttoldyou"
[5] "ohyesthatsright"
and had a list of positions that I want to replace with the character "-"
[[1]]
[1] 3 9
[[2]]
[1] 3 4
[[3]]
[1] 4 7
[[4]]
[1] 5 6 7 8 9
[[5]]
[1] 2 5 7 12
I would like to get
[1] "he-lohow-reyoudoing"
[2] "im--odhowarey...