Hi Duncan,

I at first thought that your suggestion was how the .tex file should be and that this would involve tediously editing the latex source each time I updated the .Rnw. But as you probably intended I find that I can slip the Schunks and Sinputs into the .Rnw and all still works.

Thank for that. BTW my previous "Thanks for all your help" was meant to be "Thanks to all for your help".

Cheers,  Murray

Duncan Murdoch wrote:
On 28/07/2010 6:33 PM, Murray Jorgensen wrote:
Omigod! The archival links shows that this was the same problem that caused me to give up on Sweave about 6 years ago. I guess I never properly assimilated Brian Ripley's comments at the time.

I finished up doing this:

\begin{verbatim}
 > height = scan()
1:  64 62 66 65
5:  62 69 72 72 70
10:
Read 9 items
 > part = scan(what = character(0))
1: "Soprano" "Soprano" "Soprano"
4: "Alto"    "Alto"    "Tenor"
7: "Tenor"   "Bass"    "Bass"
10:
Read 9 items
\end{verbatim}
<<echo=FALSE,results=hide>>=
height <- c(64, 62, 66, 65, 62, 69, 72, 72, 70)
part = c("Soprano","Soprano", "Soprano",
  "Alto",    "Alto",    "Tenor",
  "Tenor",   "Bass",    "Bass")
@

which does give the output I want (though in a different style) and leaves the R session in the state that I want.

If you the look to be the same as with other chunks, you should use the Sinput, Soutput and possibly Schunk environments. (Schunk normally does nothing, but you might have customized it.) That is, write your stuff as

\begin{Schunk}
\begin{Sinput}
 > height = scan()
1:  64 62 66 65
5:  62 69 72 72 70
10:
\end{Sinput}
\begin{Soutput}
Read 9 items
\end{Soutput}
\begin{Sinput}
 > part = scan(what = character(0))
1: "Soprano" "Soprano" "Soprano"
4: "Alto"    "Alto"    "Tenor"
7: "Tenor"   "Bass"    "Bass"
10:
\end{Sinput}
\begin{Soutput}
Read 9 items
\end{Soutput}
\end{Schunk}

(I suppose it's debatable whether lines to scan() should be typeset as input or output.)

Duncan Murdoch



Thanks for all your help.

Murray



David Winsemius wrote:
On Jul 27, 2010, at 7:01 AM, Murray Jorgensen wrote:

Both suggestions generate similar errors to those of the original code. I would also be worried if the results would not puzzle my students.
You are teaching them about R or about Sweave? You are setting up code that is designed to run at an open console session, but submitting it to a batch process.

http://finzi.psych.upenn.edu/R/Rhelp02/archive/31347.html

After reading that I am wondering if you could set up a textConnection first and then scan from that?

 > con <- textConnection("64 62 66 65 62\n69 72 72 70")
 > scan(file=con)
Read 9 items
[1] 64 62 66 65 62 69 72 72 70






--
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: m...@waikato.ac.nz    majorgen...@ihug.co.nz      Fax 7 838 4155
Phone  +64 7 838 4773 wk    Home +64 7 825 0441   Mobile 021 0200 8350

______________________________________________
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.

Reply via email to