Skip to content
Prev 303773 / 398502 Next

Some kind of inverse of "names"

Is this what you want?:
$a
[1] 1
$b
[1] 2
$c
[1] 3
$d
[1] 4
a b c d 
1 2 3 4
[1] 1 2 3 4

Regards
S?ren


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Julio Sergio Santana
Sent: 21. august 2012 00:20
To: r-help at r-project.org
Subject: [R] Some kind of inverse of "names"

I wonder if there exists some kind of inverse of the "names" primitive in R. Let me explain what do I mean:

If I create a list:
  -> li <- list(a=1, b=2, c=3, d=4)
then I can have:
  -> names(li)
  [1] "a" "b" "c" "d"
which is, I guess, some kind of vector, since
  -> typeof(names(li))
  [1] "character"
however, I haven't seen something that allows me to get the other side, i.e., the values.
Something like:
  ->VALUES(li)
  [1] 1 2 3 4

Do you have any comments on this?


Thanks,
  - Sergio.


______________________________________________
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.