On Fri, 2006-08-04 at 14:40 +0200, Jan Wijffels wrote: > Dear helpeRs, > > I would like to specify a newline command in R and pass it to latex > via Sweave such that it corresponds to latex' \\ command. But that > doesn't seem to be possible. If I Sweave the \n character, it just > makes a new line in latex but not the \\ command. > > Is there a way such that the following code would result in latex in > blablabla \\ blablabla on different line > > > <<echo=FALSE>>= > string <- "blablabla \\ blablabla on different line" > @ > \Sexpr{string} > > > > > Thanks for the help, > Jan
In R, the "\" is an escape character, so to get a single "\" output, you actually need to double it, "\\". Thus, to get "\\" output as part of a character vector, you would need "\\\\": > string <- "blablabla \\\\ blablabla on different line" > cat(string, "\n") blablabla \\ blablabla on different line HTH, Marc Schwartz ______________________________________________ R-help@stat.math.ethz.ch 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.