[R] Space character introduced bu paste

Karl Ove Hufthammer Karl.Hufthammer at math.uib.no
Thu Jun 5 15:54:39 CEST 2008

Karl Ove Hufthammer:

> 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'"

But a simpler solution is to use sQuote(). Note that by default this may use
directional (‘curly’) quotes. To use undirectional quotes, you can modify
the ‘useFancyQuotes’ option. Here’s an example.

$ charlist<-c("a","b","c")
$ sQuote(charlist)
[1] "‘a’" "‘b’" "‘c’"

$ options(useFancyQuotes=FALSE)
$ sQuote(charlist)
[1] "'a'" "'b'" "'c'

Karl Ove Hufthammer

More information about the R-help mailing list