Hello William,
that's exactly what I needed. I didn't consider lapply'ing over
seq_along(data) instead of data, very useful.
Thanks a lot!
Giovanni
On Mon, Aug 14, 2017 at 10:02 PM, William Dunlap wrote:
> You could replace your 'depth' argument with one that shows where in the
> original data
Hello,
I'm writing a program that takes a tree in input (nested lists) and
returns a copy of it replacing the leaves with something else (eg: a
computation done on the original leaves).
In the example below, the tree is composed by countries and cities,
and the leaves (children of the cities) are
On Fri, Aug 4, 2017 at 4:25 PM, Bert Gunter wrote:
>> f <- function(foo,bar) structure(list(bar),names =foo)
>
>> f("hello","world")
> $hello
> [1] "world"
>
> Cheers,
> Bert
Thanks Bert, I didn't know about "structure()".
Giovanni
__
R-help@r-project
Hello Thomas, Ulrik,
thanks for your suggestions.
Giovanni
On Fri, Aug 4, 2017 at 12:13 PM, Thomas Mailund
wrote:
> Do you mean like this?
>
>
>> f <- function(foo, bar) {
> + result <- list(bar)
> + names(result) <- foo
> + result
> + }
>
>> (x <- f("hello", "world"))
> $hello
> [1] "wo
Hello,
I'm having troubles defining a list where names are variables (of type
character). Like this, which gives "foo" instead of "world" (the way I
meant it is that "world" is the value of the variable foo). Any hint?
> f <- function(foo, bar) { list(foo = bar) }
> x <- f("hello", "world")
> nam
5 matches
Mail list logo