Re: [R] how to use \Sexpr{} with sweave

2007-10-09 Thread cryan
Just goes to show, it helps to search the archives!

I discovered this in the R-help archives:

https://stat.ethz.ch/pipermail/r-help/2004-July/053920.html

And similarly, in the Sweave manual:

A.16 After loading package R2HTML Sweave doesn’t work properly!

Package R2HTML registers an Sweave driver for HTML files, and after that the 
Syntax for HTML
is in the search list before the default syntax.
options(SweaveSyntax=SweaveSyntaxNoweb)
or calling Sweave like
Sweave(..., syntax=SweaveSyntaxNoweb)
ensures the default syntax even after loading R2HTML.A.16 After loading package 
R2HTML Sweave doesn’t work properly!
Package R2HTML registers an Sweave driver for HTML files, and after that the 
Syntax for HTML
is in the search list before the default syntax.

options(SweaveSyntax=SweaveSyntaxNoweb)
or calling Sweave like
Sweave(..., syntax=SweaveSyntaxNoweb)
ensures the default syntax even after loading R2HTML.

I use Tinn-R for my work, set up as per its instructions, so that when I open 
R, Tinn-R automatically opens, and in the process, it apparently loads R2HTML.  
So this explains my problem.

Does anyone know where I should put 
options(SweaveSyntax=SweaveSyntaxNoweb)?  For what command is this an 
option?

Thanks.

--Chris Ryan

 Original message 
Date: Sat,  6 Oct 2007 22:38:04 -0400 (EDT)
From: [EMAIL PROTECTED]  
Subject: [R] how to use \Sexpr{} with sweave  
To: [EMAIL PROTECTED]

I'm trying to learn Sweave.  So far things are going well with the chunks of 
code identified by  =

But I'm having trouble with the in-line text use of \Sexpr.

__
R-help@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.


Re: [R] how to use \Sexpr{} with sweave

2007-10-07 Thread Friedrich Schuster


Hi,
 this works for me (R 2.5.1, Linux): 

echo=false=
data(airquality)
library(ctest)
kruskal.test(Ozone ~ Month, data = airquality)
@
Wir haben hier also \Sexpr{nrow(airquality)} Datenzeilen in airquality.
This works
\Sexpr{2+6}

I think the error is in your latex setup, not in R or Sweave.   


ryancw wrote:
 
 I'm trying to learn Sweave.  So far things are going well with the chunks
 of code identified by  =
 
 But I'm having trouble with the in-line text use of \Sexpr.
 
 Here is a short example .Rnw file:
 
 \documentclass[12pt]{article}
 \usepackage[margin=1.25in]{geometry}
 \usepackage{graphicx}
 \usepackage{Sweave}
 
 \begin{document}
 
 test=
 pnorm(1)
 @
 
 
 \Sexpr{2+6}
 
 \end{document}
 
 The .tex file that it yields contains 
 
 \Sexpr{2+6} as its next-to-last line.  \usepackage{Sweave} is in its
 preamble.
 
 When I pdflatex that file, the resulting pdf file shows the proper value
 of pnorm(1), but it does not contain 8 near its end.  Instead it
 contains 2+6.  I had expected the computed value.
 
 Also, pdflatex gives me a message that there was an error opening the
 document.  The file cannot be found. I have to go find it and open it,
 instead of it opening automatically like a non-problematic case would.
 
 Running R 2.5.1 on WinXP, with MikTex.
 
 Any advice? Thanks.
 
 --Chris Ryan
 
 __
 R-help@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.
 
 

-- 
View this message in context: 
http://www.nabble.com/how-to-use-%5CSexpr%7B%7D-with-sweave-tf4581860.html#a13080823
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] how to use \Sexpr{} with sweave

2007-10-07 Thread Duncan Murdoch
[EMAIL PROTECTED] wrote:
 I'm trying to learn Sweave.  So far things are going well with the chunks of 
 code identified by  =

 But I'm having trouble with the in-line text use of \Sexpr.

 Here is a short example .Rnw file:

 \documentclass[12pt]{article}
 \usepackage[margin=1.25in]{geometry}
 \usepackage{graphicx}
 \usepackage{Sweave}

 \begin{document}

 test=
 pnorm(1)
 @


 \Sexpr{2+6}

 \end{document}

 The .tex file that it yields contains 

 \Sexpr{2+6} as its next-to-last line.  \usepackage{Sweave} is in its preamble.

 When I pdflatex that file, the resulting pdf file shows the proper value of 
 pnorm(1), but it does not contain 8 near its end.  Instead it contains 
 2+6.  I had expected the computed value.

 Also, pdflatex gives me a message that there was an error opening the 
 document.  The file cannot be found. I have to go find it and open it, 
 instead of it opening automatically like a non-problematic case would.

 Running R 2.5.1 on WinXP, with MikTex.

 Any advice? Thanks.
How did you produce the .tex file?  I just cut and pasted your file into 
test.Rnw, and Sweave( test.Rnw ) produced the .tex file shown below, 
with no 2+6 in it.

\documentclass[12pt]{article}
\usepackage[margin=1.25in]{geometry}
\usepackage{graphicx}
\usepackage{Sweave}

\begin{document}

\begin{Schunk}
\begin{Sinput}
  pnorm(1)
\end{Sinput}
\begin{Soutput}
[1] 0.8413447
\end{Soutput}
\end{Schunk}


8

\end{document}

__
R-help@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.


Re: [R] how to use \Sexpr{} with sweave

2007-10-07 Thread cryan
Duncan--

The .tex file that you describe as output of Sweave(test.Rnw) is what I had 
expected.  But I get this .tex file when I run Sweave:

\documentclass[12pt]{article}
\usepackage[margin=1.25in]{geometry}
\usepackage{graphicx}
\usepackage{Sweave}

\begin{document}

\begin{Schunk}
\begin{Sinput}
 pnorm(1)
\end{Sinput}
\begin{Soutput}
[1] 0.8413447
\end{Soutput}
\end{Schunk}


\Sexpr{2+6}

\end{document}\documentclass[12pt]{article}
\usepackage[margin=1.25in]{geometry}
\usepackage{graphicx}
\usepackage{Sweave}

\begin{document}

\begin{Schunk}
\begin{Sinput}
 pnorm(1)
\end{Sinput}
\begin{Soutput}
[1] 0.8413447
\end{Soutput}
\end{Schunk}


\Sexpr{2+6}

\end{document}

__
R-help@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.


Re: [R] how to use \Sexpr{} with sweave

2007-10-07 Thread cryan
I think some inadvertent cutting and pasting may have made my last e-mail 
difficult to interpret.  Here is the .tex file I get as output of Sweaving my 
.Rnw file.  Note that  \Sexpr{2+6} appears where you get (and I want) simply 
8.



\documentclass[12pt]{article}
\usepackage[margin=1.25in]{geometry}
\usepackage{graphicx}
\usepackage{Sweave}

\begin{document}

\begin{Schunk}
\begin{Sinput}
 pnorm(1)
\end{Sinput}
\begin{Soutput}
[1] 0.8413447
\end{Soutput}
\end{Schunk}


\Sexpr{2+6}

\end{document}

__
R-help@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.