Re: [R] Convert text into a variable name

From: Daniel Nordlund <djnordlund_at_verizon.net>
Date: Wed, 05 Nov 2008 22:06:14 -0800

> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] On Behalf Of Xing Yuan
> Sent: Wednesday, November 05, 2008 9:37 PM
> To: Simon Blomberg
> Cc: r-help_at_r-project.org
> Subject: Re: [R] Convert text into a variable name
>
> Thanks for the reply, Simon!
>
> I just want to name a object as the text string. So I have
> "AGE" then how
> can I do
>
> somecommand("AGE") = 39
>
> then I should have
>
> AGE = 39 in my data set.
>
>
> Joe
>
>
>
> On Thu, Nov 6, 2008 at 12:28 AM, Simon Blomberg
> <s.blomberg1_at_uq.edu.au>wrote:
>
> > ?assign
> >
> > On Thu, 2008-11-06 at 00:03 -0500, Xing Yuan wrote:
> > > Hello R users,
> > >
> > > Does anybody know what command I should use to convert
> the text string
> > "AGE"
> > > to be variable name AGE so I can assign value to it
> > > e.g. AGE = 39?
> > >
> > > Thank you very much!
> > >
> > > Joe

Simon gave you the answer. The command is the function assign(). Type ?assign at the R console prompt to read about the function.

Dan

Daniel Nordlund
Bothell, WA USA



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 Thu 06 Nov 2008 - 06:31:08 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 Thu 06 Nov 2008 - 07:30:25 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