Re: [R] escape character to get " printed in output
Gabor & Marc, Yes, you are right. Thanks for clarifying that for me. I should have tested it fully before hand. Thanks, Roger -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Thursday, November 30, 2006 3:12 PM To: roger bos Cc: RHelp Subject: Re: [R] escape character to get " printed in output It did work. That's how print represents strings. Try: > cat("hello \"hello\" hello") hello "hello" hello> > strsplit("hello \"hello\" hello", "")[[1]] [1] "h" "e" "l" "l" "o" " " "\"" "h" "e" "l" "l" "o" "\"" " " "h" [16] "e" "l" "l" "o" On 11/30/06, roger bos <[EMAIL PROTECTED]> 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 > > __ > 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. > ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ 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.
Re: [R] escape character to get " printed in output
It did work. That's how print represents strings. Try: > cat("hello \"hello\" hello") hello "hello" hello> > strsplit("hello \"hello\" hello", "")[[1]] [1] "h" "e" "l" "l" "o" " " "\"" "h" "e" "l" "l" "o" "\"" " " "h" [16] "e" "l" "l" "o" On 11/30/06, roger bos <[EMAIL PROTECTED]> 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 > > __ > 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. > __ 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.
Re: [R] escape character to get " printed in output
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 __ 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.
[R] escape character to get " printed in output
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 __ 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.