[R] Backslash in paste() function
Stefan Petersson
stefan.petersson at inizio.se
Wed Jun 16 09:49:29 CEST 2010
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
>
More information about the R-help
mailing list