Hi all,

I have a string vector like that: x=c("1\t\t", "2", "3\t\t\t")
I need to remove all the occurrences of "\t", in order to obtain: x = "1"
"2"   "3"

I'm trying to use the function substring2, and it works for each component,
for example:
substring2(x[1], "\t") =""
gives x = "1"   "2"   " 3\t\t\t"

I'd like to apply this function to each component and I tried the following:

myfun = function(x, i) {
  substring2(x[i], "\t") = ""
}

lapply(x, myfun)

which gives x="" "" ""

I know that I'm wrong somewhere using lapply, but I can't fix it.

Thanks in advance,
Arnaud Chozo

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to