[R] Sweave - problems with underscores in variable names...

From: Neil Shephard <nshephard_at_gmail.com>
Date: Thu 16 Feb 2006 - 18:59:46 EST


Hi all,

I've just started using the Friedrich Leisch's Sweave package to generate LaTeX reports with results of my analyses embedded as required.

I've encountered a bit of a problem though in the processing of the resulting *.tex file that is as far as I can tell, down to the fact that my variable names have underscores ('_') in their names.

The relevant section of code is....

 <<missing_data,echo=false,results=tex>>= ## Lists observations with missing data
miss_1431 <- subset(gen, PPARG1.2_1431GA == "", select= c(AAA_ID,PPARG1.2_1431GA))
xtable(miss_1431, caption="Missing data for PPARG1.2-1431GA") miss_p12a <- subset(gen, PPARG2_P12A_CG == "", select= c(AAA_ID,PPARG2_P12A_CG)) xtable(miss_p12a, caption="Missing data for PPARG2-P12A_CG")

@

and the variables in my data set have the following names...

> names(gen)

[1] "AAA_ID"          "OPN_1083AG"      "OPN_1239AC"      "OPN_282TC"
[5] "OPN_750CT"       "OPN_443CT"       "PPARG1.2_1431GA" "PPARG2_P12A_CG"
[9] "OPG_1181GC"

In tables that are generated have the character after the subscript subscripted, as opposed to being displayed as desired (see pg 4 of example output at
http://slack.ser.man.ac.uk/files/genetic_analysis.pdf , please ignore the table on pg 3, as I said I'm just starting :-).

After googling and searching R-help archives didn't reveal any obvious problems with this (other than in older versions of R underscores were not allowed in variable names).

My question is, other than the obvious of renaming my variables, or manually editing the .tex file that Sweave produces, is there any way to have variable names with underscores correctly represented in the resulting tex file?

The error log-file generated when running pdflatex on the .tex file can be viewed at http://slack.ser.man.ac.uk/files/genetic_analysis.log

Please let me know if I need to provide any more information, and my thanks in advance,

Neil

> version

         _
platform i686-pc-linux-gnu

arch     i686
os       linux-gnu

system i686, linux-gnu
status
major 2
minor 2.1
year 2005
month 12
day 20
svn rev 36812
language R
--
"Once, adv. - Enough
Twice, adv. - Once too often"
 - Ambrose Bierce, The Devil's Dictionary

Email - nshephard@gmail.com
Website - http://slack.ser.man.ac.uk/
Blog - http://slack---line.blogspot.com/
Flickr - http://www.flickr.com/photos/slackline/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Feb 16 19:04:17 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:31 EST