Hi Florian,
Have you tried to replace each '\n' with '\r\n'. That did the
trick for
me.
HTH,
Thierry
------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium
Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx at inbo.be
www.inbo.be
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data.
~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] Namens Florian Burkart
> Verzonden: donderdag 10 juni 2010 14:44
> Aan: r-help at 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 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.
>
Druk dit bericht a.u.b. niet onnodig af.
Please do not print this message unnecessarily.
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in this message
and any annex are purely those of the writer and may not be regarded as stating
an official position of INBO, as long as the message is not confirmed by a duly
signed document.