[R] Create and Assign value into a variable from Another variable

Jessica Streicher j.streicher at micromata.de
Tue Aug 28 11:28:46 CEST 2012


This?

> x<-"y"
> assign(x,1)
> y
[1] 1


On 28.08.2012, at 10:16, Bert Gunter wrote:

> Post a small reproducible example to clarify what you want to do.
> 
> -- Bert
> 
> On Mon, Aug 27, 2012 at 11:48 PM, Rantony <antony.akkara at ge.com> wrote:
>> Hi,
>> 
>> Here i have a variable named "MyVariable" containing particular name
>> 
>> For eg:-
>> MyVariable <- "UnitNo"
>> 
>> Here my requirement is, i need to get "UnitNo" as another variable by
>> reading "MyVariable"
>> 
>> i need  "UnitNo" as variable name and need to assign some value into that.
>> 
>> i had tried with as.name(MyVariable ) and as.character(MyVariable) - Its
>> getting that value, but im unable to assign
>> something into that variable.
>> 
>> Could you please help me ?
>> 
>> - Thank you
>> Antony
>> 
>> 
>> 
>> --
>> View this message in context: http://r.789695.n4.nabble.com/Create-and-Assign-value-into-a-variable-from-Another-variable-tp4641515.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.
> 
> 
> 
> -- 
> 
> Bert Gunter
> Genentech Nonclinical Biostatistics
> 
> Internal Contact Info:
> Phone: 467-7374
> Website:
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
> 
> ______________________________________________
> 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.




More information about the R-help mailing list