tfire, TIBCO Software
wdunlap tibco.com
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org
] On Behalf
Of Sam Steingold
Sent: Monday, November 19, 2012 10:07 AM
To: r-help@r-project.org
Subject: [R] generated list element names
How can I create lis
I missed the last snipet; just saw the first. So you have your
solution. If you want a function, try:
> f.newList <- function(x,name){.x <- list(x);names(.x) <- name;.x}
> f.newList(10, paste('f', 'oo', sep = ''))
$foo
[1] 10
On Mon, Nov 19, 2012 at 1:32 PM, Sam Steingold wrote:
>> * jim holt
nal Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Sam Steingold
> Sent: Monday, November 19, 2012 10:07 AM
> To: r-help@r-project.org
> Subject: [R] generated list element names
>
> How can I create lists
> * jim holtman [2012-11-19 13:14:05 -0500]:
>
> How about this (if you don't like writing two lines, encapsulate it in
> a function):
>
>> x <- list(10)
>> names(x) <- paste('f', 'oo', sep = '')
>> str(x)
> List of 1
> $ foo: num 10
>>
I am sorry, how is this different from my second snippet (e
How about this (if you don't like writing two lines, encapsulate it in
a function):
> x <- list(10)
> names(x) <- paste('f', 'oo', sep = '')
> str(x)
List of 1
$ foo: num 10
>
On Mon, Nov 19, 2012 at 1:07 PM, Sam Steingold wrote:
> How can I create lists with element names created on the fly?
How can I create lists with element names created on the fly?
--8<---cut here---start->8---
> list (foo = 10)
$foo
[1] 10
> list ("foo" = 10)
$foo
[1] 10
> list (paste("f","oo",sep="") = 10)
Error: unexpected '=' in "list (paste("f","oo",sep="") ="
--8<---
6 matches
Mail list logo