[R] Backslash in paste() function

From: Stefan Petersson <stefan.petersson_at_inizio.se>
Date: Wed, 16 Jun 2010 09:49:29 +0200

Hi,

I'm trying to build a vector of latex commands. However, I need the command strings to begin with a backslash "\". I have:

test <- c('foo','bar')

and I need to rebuild the array, encapsulating the text items with latex stuff, like this:

paste("\parbox[b]{3cm}{", test, "}", fill=TRUE)

Actually, cat() prints the string fine if one uses double backslashes. However, I can't save the result from cat() back to a vector. And when I use cat() inside the latex function from the Hmisc package, I only get errors... The (not so) funny thing is that I can use paste() on a few latex commands. So if I needed to make the strings bold, the following works:

paste("\bfseries{", test, "}")

I've read the R FAQ 7.37, but it only deals with cat(). Not paste. Or I just didn't get it :o/

Is there a way to paste() the backslash character?

> sessionInfo()

R version 2.11.1 (2010-05-31)
i486-pc-linux-gnu

locale:

 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
 [5] LC_MONETARY=C             LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=en_US.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

>


R-help_at_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. Received on Wed 16 Jun 2010 - 07:54:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Jun 2010 - 12:10:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive