Re: [R] Creating named lists

2010-03-12 Thread Henrique Dallazuanna
One option is this: eapply(globalenv(), I)[c('a', 'b')] On Fri, Mar 12, 2010 at 6:45 AM, Rune Schjellerup Philosof wrote: > No, I mean this: > a <- 1 > b <- 2 > list(a=a, b=b) > > I just find it anoying, that I have to type the names of the variables > twice. > I would like something like this

Re: [R] Creating named lists

2010-03-12 Thread Duncan Murdoch
ject.org [mailto:r-help-boun...@r-project.org] På vegne af Rune Schjellerup Philosof Sendt: 12. marts 2010 10:46 Til: Linlin Yan Cc: r-help@r-project.org Emne: Re: [R] Creating named lists No, I mean this: a <- 1 b <- 2 list(a=a, b=b) I just find it anoying, that I have to type the names of th

Re: [R] Creating named lists

2010-03-12 Thread Rune Schjellerup Philosof
meddelelse- > Fra: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] På > vegne af Rune Schjellerup Philosof > Sendt: 12. marts 2010 10:46 > Til: Linlin Yan > Cc: r-help@r-project.org > Emne: Re: [R] Creating named lists > > No, I mean this: > a <-

Re: [R] Creating named lists

2010-03-12 Thread Søren Højsgaard
Sendt: 12. marts 2010 10:46 Til: Linlin Yan Cc: r-help@r-project.org Emne: Re: [R] Creating named lists No, I mean this: a <- 1 b <- 2 list(a=a, b=b) I just find it anoying, that I have to type the names of the variables twice. I would like something like this instead: list(a, b, us

Re: [R] Creating named lists

2010-03-12 Thread Miguel Porto
Hi See if this function works for you (I didn't properly test it...): nlist=function(...) { a=list(...); names(a)=as.character(match.call()[2:(length(a)+1)]) return(a); } Ex: > a=1:3 > b=matrix(1:10,nc=2) > nlist(a,b) $a [1] 1 2 3 $b [,1] [,2] [1,]16 [2,]27 [3,]

Re: [R] Creating named lists

2010-03-12 Thread Rune Schjellerup Philosof
Because I was simplifying the use case to make an example. The variables are often created during various computations in functions and in order to return more than one value from a function I have to create a list. Wrapping everything in a list statement would make it harder to read and make debug

Re: [R] Creating named lists

2010-03-12 Thread Erich Neuwirth
If thats what you want, why don't you do list(a=1, b=2) On 3/12/2010 10:45 AM, Rune Schjellerup Philosof wrote: > No, I mean this: > a <- 1 > b <- 2 > list(a=a, b=b) > > I just find it anoying, that I have to type the names of the variables > twice. > I would like something like this instead: >

Re: [R] Creating named lists

2010-03-12 Thread Gesmann, Markus
I think, you are looking for ?llist in the package Hmisc. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rune Schjellerup Philosof Sent: 12 March 2010 09:46 To: Linlin Yan Cc: r-help@r-project.org Subject: Re: [R] Creating named

Re: [R] Creating named lists

2010-03-12 Thread Rune Schjellerup Philosof
No, I mean this: a <- 1 b <- 2 list(a=a, b=b) I just find it anoying, that I have to type the names of the variables twice. I would like something like this instead: list(a, b, use.var.names=TRUE) -- Rune Linlin Yan wrote: > Did you mean this: > > >> n <- c('a', 'b') >> structure(list(1, 2),

Re: [R] Creating named lists

2010-03-12 Thread Linlin Yan
Did you mean this: > n <- c('a', 'b') > structure(list(1, 2), names = n) $a [1] 1 $b [1] 2 On Fri, Mar 12, 2010 at 5:28 PM, Rune Schjellerup Philosof wrote: > I often find myself making lists similar to this > list(var1=var1, var2=var2) > > It doesn't seem list has an option, to make it use th

[R] Creating named lists

2010-03-12 Thread Rune Schjellerup Philosof
I often find myself making lists similar to this list(var1=var1, var2=var2) It doesn't seem list has an option, to make it use the name of the variable as name in the list. Is there another function that does this? -- Med venlig hilsen Rune Schjellerup Philosof Ph.d-stipendiat, Forskningsenhede