[R] working on a vector with named elements - unname
Alexander
juschitz_alexander at yahoo.de
Wed Feb 15 10:43:17 CET 2012
Hi, I am working under R2.11.1 Windows.
I work with a set of parameters which is save under a vector. I think it is
easier to understand, which parameter is called in the vector by naming all
vector elements. For example, we have a vector which the parameters a,b,c,d.
Is it normal to allow, that there are two elements with the same name? I
think for lists, it is also possible. If I want to regroup the elements and
work on them, they always keep their old name. Event if I attribute to a new
name, the new name and the old name merge (lign3)
v<-c("a"=3,"a"=4,"c"=5,"d"=6)
v["a"] #output 3
c("n"=v["a"]+v["c"],"n1"=v["d"]*3) # "n.a"=8 "n1.d"=18
Is there any better solution/datatype to this ?
c("n"=unname(v["a"])+unname(v["c"]),"n1"=unname(v["d"])*3) # "n"=8 "n1"=18
Thanks a lot
--
View this message in context: http://r.789695.n4.nabble.com/working-on-a-vector-with-named-elements-unname-tp4389930p4389930.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list