Convert text into a variable name

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Convert text into a variable name

Xing Yuan
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

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Convert text into a variable name

Simon Blomberg-4
?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
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
--
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
Faculty of Biological and Chemical Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for
an answer does not ensure that a reasonable answer can
be extracted from a given body of data. - John Tukey.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Convert text into a variable name

Xing Yuan
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 <[hidden email]>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
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] 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.
> --
> Simon Blomberg, BSc (Hons), PhD, MAppStat.
> Lecturer and Consultant Statistician
> Faculty of Biological and Chemical Sciences
> The University of Queensland
> St. Lucia Queensland 4072
> Australia
> Room 320 Goddard Building (8)
> T: +61 7 3365 2506
> http://www.uq.edu.au/~uqsblomb <http://www.uq.edu.au/%7Euqsblomb>
> email: S.Blomberg1_at_uq.edu.au
>
> Policies:
> 1.  I will NOT analyse your data for you.
> 2.  Your deadline is your problem.
>
> The combination of some data and an aching desire for
> an answer does not ensure that a reasonable answer can
> be extracted from a given body of data. - John Tukey.
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Convert text into a variable name

Daniel Nordlund-2
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Xing Yuan
> Sent: Wednesday, November 05, 2008 9:37 PM
> To: Simon Blomberg
> Cc: [hidden email]
> 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
> <[hidden email]>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

______________________________________________
[hidden email] 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.