Re: [R] change the value of vector based on the string of its name

2017-03-25 Thread Jim Lemon
Hi Qill, If I have interpreted your example correctly: proc1<-0 proc2<-0 cpd<-c("proc1","proc2") assign("proc1",which(cpd=="proc1")) Jim On Sat, Mar 25, 2017 at 4:12 AM, Qill Bel wrote: > Dear R-users, > > Imagine I have 3 vectors: > *proc1<-0* > *proc2<-0* > *cpd<-c("proc1","proc2")* > > How

Re: [R] change the value of vector based on the string of its name

2017-03-24 Thread David Winsemius
> On Mar 24, 2017, at 10:12 AM, Qill Bel wrote: > > Dear R-users, > > Imagine I have 3 vectors: > *proc1<-0* > *proc2<-0* > *cpd<-c("proc1","proc2")* The `cpd` vector has only character values in it, and has no relation to either the `proc1` or `proc2` vectors. If you want it refer to them (

[R] change the value of vector based on the string of its name

2017-03-24 Thread Qill Bel
Dear R-users, Imagine I have 3 vectors: *proc1<-0* *proc2<-0* *cpd<-c("proc1","proc2")* How can I change the value of proc1 to 1, based on vector cpd only? I tried with *as.factor(cpd[1])<-1*, but it produces an error. Any idea how could I achieve that? [[alternative HTML version delete