Re: [R] how to input a string without quote

From: Yihui Xie <xieyihui_at_gmail.com>
Date: Sun, 30 Nov 2008 15:32:35 +0800

Wow, you are so lazy... But sometimes R is just designed for lazy guys...

##
f = function(a) {

    s = substitute(a)
    as.character(s)
}
##

> f(a = asdf)

[1] "asdf"
> f(qwer)

[1] "qwer"

Regards,
Yihui

--
Yihui Xie <xieyihui_at_gmail.com>
Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086
Mobile: +86-15810805877
Homepage: http://www.yihui.name
School of Statistics, Room 1037, Mingde Main Building,
Renmin University of China, Beijing, 100872, China



On Sat, Nov 29, 2008 at 10:59 PM, Gabor Grothendieck
<ggrothendieck_at_gmail.com> wrote:

> This works if you type it in from the R console:
>
>> s <- readline()
> this is my string
>
>> s
> [1] "this is my string"
>
>
>
> On Sat, Nov 29, 2008 at 9:41 AM, Jinsong Zhao <jszhao_at_mail.hzau.edu.cn> wrote:
>> Hi there,
>>
>> I hope to use a string as an input in my function, however, I don't want
>> to input the quotation mark. Is it possible?
>>
>> Thanks in advance.
>>
>> Regards,
>> Jinsong
>>
______________________________________________ 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.
Received on Sun 30 Nov 2008 - 07:35:49 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 30 Nov 2008 - 08:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive