[R] How do I paste double quotes arround a character string?
(Ted Harding)
Ted.Harding at manchester.ac.uk
Thu Jul 3 12:08:39 CEST 2008
Hi Philip,
I think a bit more clarification may be useful yet!
1: How are you sending the command from R to Linux?
2: What is the command intended to be (as seen by Linux)?
And from what source (quasi-command line; script file; ...)
would it be read by Linux?
For example, on my Linux machine, I just did (in a shell
command line):
ted at deb:~$ touch "New Mexico"
ted at deb:~$ ls -l "New Mexico"
-rw-r--r-- 1 ted ted 0 2008-07-03 10:58 New Mexico
and then, in R, I did:
> system("ls -l \"New Mexico\"")
-rw-r--r-- 1 ted ted 0 2008-07-03 10:58 New Mexico
so I don't seem to have had the problem you describe below.
On the other hand, back in Linux, if I do:
ted at deb:~$ ls -l \"New Mexico\"
ls: "New: No such file or directory
ls: Mexico": No such file or directory
which looks like the problem you describe -- so clearly the
command did not get through in that form from R using the
command system("ls -l \"New Mexico\"").
Best wishes,
Ted.
On 03-Jul-08 09:18:14, Philip James Smith wrote:
> Thanks for your reply, Ted... I am very grateful for it.
>
> Using your notation, what I need is a character string Y that looks
> like:
>
> >
> > Y
> >[1] ""New Mexico""
>
> rather than
>
> > Y
> >[1] "\"New Mexico\""
>
> i.e., Y must have the string 'New Mexico' surrounded by double quotes,
> rather than double quotes preceded by slashes.
>
> The reason why I need it that way is that I've over simplified my
> request and the character string is actually a unix command that needs
> to be surrounded by double quotes when embeded in the unix (linux)
> executes it. When unix sees that slash before the quotes, it gives an
> error.
>
> I'd be grateful if you can provide a solution to this!!
>
> Thank you, Ted!
>
> Gratefully,
> Phil Smith
> Duluth, GA
>
>
> (Ted Harding) wrote:
>> On 03-Jul-08 01:25:55, Philip James Smith wrote:
>>
>>> Hi R Community:
>>> I've got a character string that looks like: New Mexico
>>>
>>> How to I create the new character string that looks like: "New
>>> Mexico"
>>> That is, it is the original string (New Mexico) with double quotes
>>> infront and behind it?
>>>
>>> Thanks,
>>> Phil Smith
>>>
>>
>> I tried the following. Is that the sort of thing you want to achieve?
>>
>> X<-"New Mexico"
>> Y<-"\"New Mexico\""
>> X
>> # [1] "New Mexico"
>> Y
>> # [1] "\"New Mexico\""
>> plot((1:10),xlab=X,ylab=Y)
>>
>> Best wishes,
>> Ted.
>>
>> --------------------------------------------------------------------
>> E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
>> Fax-to-email: +44 (0)870 094 0861
>> Date: 03-Jul-08 Time: 09:22:10
>> ------------------------------ XFMail ------------------------------
>>
>>
>
> ______________________________________________
> 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.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 03-Jul-08 Time: 11:08:36
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list