Re: [R] assign a value to an element

2012-03-19 Thread John Kane
I am not sure that I understand but does something like this do what you want? ec<-1:10 vec[vec==4] <- 100 vec <- 1:10 vec[ vec==4 | vec==8] <- 100 vec <- 1:10 aa <- 50 vec[vec==4] <- aa John Kane Kingston ON Canada > -Original Message- > From: marc_...@yahoo.fr > Sent: Sun, 18 Mar 2

Re: [R] assign a value to an element

2012-03-18 Thread David Winsemius
On Mar 18, 2012, at 2:24 PM, Marc Girondot wrote: Assign can be used to set a value to a variable that has name as a value of another variable. Example: name<-"essai" assign(name, "plouf") essai [1] "plouf" OK. But how to do the same when it is only an element of a vector, data frame an

Re: [R] assign a value to an element

2012-03-18 Thread William Dunlap
Do not use assign(). It is a relic from the 1980s. Instead, decide where you want your variables to live, perhaps in a list, where<-list() or perhaps in an environment, where<-new.env() or where<-environment(). Then use where[[varName]] to refer to the variable. You can use further subse