[R] define a list with names as variables
Giovanni Gherdovich
g.gherdovich at gmail.com
Fri Aug 4 12:36:49 CEST 2017
Hello Thomas, Ulrik,
thanks for your suggestions.
Giovanni
On Fri, Aug 4, 2017 at 12:13 PM, Thomas Mailund
<thomas.mailund at gmail.com> wrote:
> Do you mean like this?
>
>
>> f <- function(foo, bar) {
> + result <- list(bar)
> + names(result) <- foo
> + result
> + }
>
>> (x <- f("hello", "world"))
> $hello
> [1] "world"
>
>> names(x)
> [1] "hello"
On Fri, Aug 4, 2017 at 12:14 PM, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote:
> Hi Giovani,
>
> I would create an unnamed list and set the names after.
>
> Best,
> Ulrik
More information about the R-help
mailing list