On 3/20/07, Ernest Turro <[EMAIL PROTECTED]> wrote: > > On 20 Mar 2007, at 07:53, Martin Maechler wrote: > > >>>>>> "Wolfi" == Wolfgang Huber <[EMAIL PROTECTED]> > >>>>>> on Mon, 19 Mar 2007 15:38:00 +0000 writes: > > > >>> the problem with results=hide is that it suppresses everything. I > >>> just > >>> need Sweave to suppress strings ending in '\r'... > > > > > > Wolfi> Dear Ernest, > > > > Wolfi> IMHO it is good practice to make the printing of these > > progress reports > > Wolfi> ("sweep 4 of 1024\r") optional and produce them only if > > the user calls > > Wolfi> your function with, say, "verbose=TRUE", > > > > I strongly agree. > > > > Wolfi> and furthermore set the default value of the > > Wolfi> 'verbose' argument to "verbose=interactive()". > > > > or -- typically my choice -- to 'verbose = getOption("verbose") > > > > Martin Maechler, ETH Zurich > > > > Wolfi> Best wishes > > Wolfi> Wolfgang > > > > [............] > > > > I agree that users should be free to choose the level of verbosity. > Here, I want to show the verbose output and print it onto the tex > file using Sweave to give users a good idea of what happens. What I > don't want is countless lines being printed because \r is being > interpreted as \n ...
In cases like this capture.output() is your friend. Write one code chunk with results=hide,echo=FALSE that uses capture.output to trap the desired output as character strings then use string manipulation functions to do the desired replacement. A second code chunk with eval=FALSE shows the code that apparently produces the output and a third code chunk with echo=FALSE uses cat on the manipulated character strings with quote=FALSE to show what apparently was produced. > >>>> Ernest Turro wrote: > >>>>> Dear all, > >>>>> I have a code chunk in my Rnw file that, when executed, outputs > >>>>> carriage return characters ('\r') to inform on the progress (e.g. > >>>>> "sweep 4 of 1024\r"). But Sweave interprets this as a newline > >>>>> character, and therefore I get countless pages of output in my > >>>>> vignette where I only really want one line. Any ideas? > >>>>> Thanks > >>>>> E > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel