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,
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
rphilo...@health.sdu.dk wrote:
I often find myself making lists similar to this
list(var1=var1, var2=var2)
It doesn't seem list has an option,
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), names =
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
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:
list(a, b,
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
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,]
. 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, use.var.names=TRUE)
--
Rune
[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
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, use.var.names=TRUE
One option is this:
eapply(globalenv(), I)[c('a', 'b')]
On Fri, Mar 12, 2010 at 6:45 AM, Rune Schjellerup Philosof
rphilo...@health.sdu.dk 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
11 matches
Mail list logo