-----Oorspronkelijk bericht-----
Van: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] Namens Florian Burkart
Verzonden: donderdag 10 juni 2010 14:44
Aan: r-help@r-project.org
Onderwerp: [R] Sweave cutting new lines
Hi,
I have trouble with Sweave (I think) cutting of my newlines.
As stated in the help of Sweave, I generate tex code straight
from R for dynamically computed reports.
If I do this in R:
for (i in 0:4) {cat("\n",i,"\n")};cat("\n 3")
0
1
2
3
4
3
The output looks correct.
However, Sweave for some reason seems to trim everything
outside forloops. Hence, this
<<results=tex,echo=FALSE>>=
sec<-0
lambda<-0
chartvalue<-"b"
relsec<-0
for (chartvalue in c("b","beta")) {
for (relsec in 0:(e("count pd")-2)) {
file<-paste("working/frontfile",sec,"x",lambda,"x",chartvalue,
"x",relsec,".pdf",sep="")
pdf(file=file,paper="special",width=14,height=6)
correl.plotsinglechart(sec,lambda,chartvalue,relsec)
tmp<-dev.off()
cat("\\includegraphics{",file,"}\n\n",sep="")
}
}
chartvalue<-"rsq"
relsec<-0
file<-paste("working/frontfile",sec,"x",lambda,"x",chartvalue,
"x",relsec,".pdf",sep="")
pdf(file=file,paper="special",width=14,height=6)
correl.plotsinglechart(sec,lambda,chartvalue,relsec)
tmp<-dev.off()
cat("\n\\newline\\includegraphics{",file,"}\n\n",sep="")
@
gets converted to this
\includegraphics{working/frontfile0x0xbx0.pdf}
\includegraphics{working/frontfile0x0xbx1.pdf}
\includegraphics{working/frontfile0x0xbx2.pdf}
\includegraphics{working/frontfile0x0xbetax0.pdf}
\includegraphics{working/frontfile0x0xbetax1.pdf}
\includegraphics{working/frontfile0x0xbetax2.pdf}\newline\incl
udegraphics{working/frontfile0x0xrsqx0.pdf}
This actually works now because the \newline takes care of
the line break, but it is not very pretty.
Does anyone know why Sweave behaves this way? Is there a way
to fix it
(besides working in another R chunk)? Maybe I am just being silly...
Thanks
______________________________________________
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.