Hi I have a variable str = " X", "Y" and values ("0","12") i want to set value for X =0 and Y =12 and use inside the program. how to do this Please anybody help me. -- View this message in context: http://r.789695.n4.nabble.com/Setting-the-Values-tp3823388p3823388.html Sent from the R help mailing list archive at Nabble.com.
Take a look at assign(), but you may want to add some code to make sure variables with those names don't already exist. Something like: str = c("X","Y") val = c("0","12") mapply(function(name,value){assign(name,as.double(value),envir=.GlobalEnv)}, str,val) Hope this helps, Michael Weylandt On Mon, Sep 19, 2011 at 5:20 AM, arunkumar1111 <akpbond007@gmail.com> wrote:> Hi > > I have a variable str = " X", "Y" and values ("0","12") > > i want to set value for X =0 and Y =12 and use inside the program. > how to do this > Please anybody help me. > > -- > View this message in context: > http://r.789695.n4.nabble.com/Setting-the-Values-tp3823388p3823388.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
Hi, X = 0 Y =12 works for me. If you judge my answer as too vague, please reread your original post and kindly post the code you used to define the objects you are mentioning. Thanks, JC 2011/9/19 arunkumar1111 <akpbond007 at gmail.com>:> Hi > > I have a variable str = " X", "Y" and values ("0","12") > > ?i want to set value for X =0 and Y =12 and use inside the program. > how to do this > Please anybody help me. > > -- > View this message in context: http://r.789695.n4.nabble.com/Setting-the-Values-tp3823388p3823388.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >