[R] Space character introduced bu paste

Karl Ove Hufthammer Karl.Hufthammer at math.uib.no
Thu Jun 5 15:48:53 CEST 2008


tolga.i.uzuner at jpmorgan.com:

>> charlist<-c("a","b","c")
>> lapply(charlist, function (y) paste("'",y,"'"))

Use 'sep=""'. And using 'sapply' instead of 'lapply' gives a nicer input.
The following works.

$ sapply(charlist, function(y) paste("'",y,"'", sep=""))
    a     b     c
"'a'" "'b'" "'c'"

-- 
Karl Ove Hufthammer



More information about the R-help mailing list