[R] escape character to get " printed in output
    Marc Schwartz 
    marc_schwartz at comcast.net
       
    Thu Nov 30 21:14:43 CET 2006
    
    
  
On Thu, 2006-11-30 at 15:05 -0500, roger bos wrote:
> I want to use R to run dos commands (either by create batch files or
> using shell())and I need to write double quotes on the file (or shell
> command).  As an easier example, lets take:
> 
> > print("hello 'hello' hello")
> [1] "hello 'hello' hello"
> 
> Lets say instead of the above, I wanted:
> "hello "hello" hello"
> If possible, how would I do that?
> 
> I understand that \ is an escape character, so I tried:
> 
> > print("hello \"hello\" hello")
> [1] "hello \"hello\" hello"
> 
> But that did not work.
> 
> TIA, Roger
Roger,
Don't use print(), use cat() so that the escaped characters are properly
interpreted:
> cat("hello \"hello\" hello\n")
hello "hello" hello
> 
See ?cat
HTH,
Marc Schwartz
    
    
More information about the R-help
mailing list