[R] How not to print '\\' as '\\'

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Jul 9 14:24:31 CEST 2010


On Tue, 2010-07-06 at 19:08 -0700, Joshua Wiley wrote:
> Try cat(), for instance:
> 
> > cat("\\\n")
> \
> >
> 
> The extra \n is needed for a proper line break.

Or

writeLines("\\")

Which handles the newline for you. ?writeLines.

HTH

G

> 
> HTH,
> 
> Josh
> 
> On Tue, Jul 6, 2010 at 7:01 PM, thmsfuller066 at gmail.com
> <thmsfuller066 at gmail.com> wrote:
> > Hello All,
> >
> > '\\' is printed as '\\', but it is actually only one character.
> > Sometimes, I'd rather print it as a single '\'. Is there a function to
> > do so in R?
> >
> >> nchar('\\')
> > [1] 1
> >> print('\\')
> > [1] "\\"
> >
> > --
> > Tom
> >
> > ______________________________________________
> > 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.
> >
> 
> 
> 

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list