You should try:
eapply(.GlobalEnv, I)[c('b', 'my.c')]
On Thu, Sep 30, 2010 at 8:49 AM, Hans Ekbrand
<[email protected]>wrote:
> If I combine elements into a list
>
> b <- c(22.4, 12.2, 10.9, 8.5, 9.2)
> my.c <- sample.int(round(2*mean(b)), 5)
> my.list <- list(b, my.c)
>
> the names of the elements seems to get lost in the process:
>
> > str(my.list)
> List of 2
> $ : num [1:5] 22.4 12.2 10.9 8.5 9.2
> $ : int [1:5] 11 8 6 9 20
>
> If I explicitly name the elements at list-creation, I get what I want:
>
> my.list <- list(b=b, my.c=my.c)
>
> > str(my.list)
> List of 2
> $ b : num [1:5] 22.4 12.2 10.9 8.5 9.2
> $ my.c: int [1:5] 11 8 6 9 20
>
>
> Now, is there a way to get list() (or some other function) to
> automatically name the elements?
>
> I often use list() in return(), and I am getting tired of having to
> repeat myself.
>
> --
> Hans Ekbrand (http://sociologi.cjb.net) <[email protected]>
> A. Because it breaks the logical sequence of discussion
> Q. Why is top posting bad?
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkykeUwACgkQfCyHKnBQYU4J+ACgrdjMSoyr/Uzt9fpTsietde3n
> d8UAnRskbOM7mDhDexiS7T9LkhRs287P
> =MsDG
> -----END PGP SIGNATURE-----
>
> ______________________________________________
> [email protected] 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.
>
>
--
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O
[[alternative HTML version deleted]]
______________________________________________
[email protected] 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.