[R] Problem: Sweave and math environments

From: Christian Reisinger <creisinger_at_gsss.uni-bremen.de>
Date: Tue, 04 Nov 2008 12:16:16 +0100


Dear list,

I using R as the statistical package for my dissertation in political sciences and I am using Sweave for documenting the work done for the creation of my dataset. However, I have a problem with Sweave (which is great, by the way) which is (hopefully) easy to solve:

I want Sweave to "echo" my code, so that the R source code of the code chunks appears in the Latex document. However, since I am using several $ signs per line, as in the example line below, Latex interprets this as a math environment, despite the fact that the $ signs are within the {Sinput} environment. The problem now is that I sometimes have an unequal number of $ signs in an input line, so that LaTex thinks that all of the following "normal" text is still part of the math environment, and formats it accordingly.

This is an example input line:

Pre_Year <- MyMain3$Con_Stat[MyMain3$MyID==ID_Count[i] & MyMain3$MyYear==Count_Years[y-1]]

where I have three $ sings, and LaTex thinks that everything following the last $ sign is still part of a formula.

I have two question now:
1. Is there any way to solve the problem within Sweave itself, e.g. through setting options?
2. If not: is there a way to generally turn off the math mode in LaTex in the preamble, since I generally don't need it? (Maybe I should better post this in the LaTex mailing list, but maybe some people here had similar problems)

Thanks for all comments!
Best,
Christian

PS: I tried to replace all $ signs by \$, but this did not work either and caused many LaTex errors.

-- 
Ph.D. Candidate
Graduate School of Social Sciences
FVG-West
Wiener Straße/Ecke Celsiusstr.
28334 Bremen
Germany

Tel: +49 (0)421 218 4156

http://www.gsss.uni-bremen.de
creisinger_at_gsss.uni-bremen.de

______________________________________________
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 Tue 04 Nov 2008 - 13:56:06 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 Tue 04 Nov 2008 - 14:30:21 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