It worked for me.
string1 <- "hello stackoverflow" paste((strsplit(string1, "")[[1]])[-c(4,10,18)],collapse="") [1] "helo stakoverflw"
I used strsplit to split a string into a character vector, and then insert only the characters you strsplit back into the string.
You can also write a function that does this:
delChar <- function(x,eliminate){ paste((strsplit(x,"")[[1]])[-eliminate],collapse = "") } delChar(string1,c(4,10,18)) [1] "helo stakoverflw"
source share