search for: gherdovich

Displaying 8 results from an estimated 8 matches for "gherdovich".

2017 Aug 04
4
define a list with names as variables
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") > names(x) [1] "foo"
2017 Aug 04
1
define a list with names as variables
...like this? > f <- function(foo, bar) { + result <- list(bar) + names(result) <- foo + result + } > (x <- f("hello", "world")) $hello [1] "world" > names(x) [1] "hello" -- Thomas Mailund On 4 August 2017 at 12.08.28, Giovanni Gherdovich (g.gherdovich at gmail.com) wrote: 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 &...
2017 Aug 04
0
define a list with names as variables
Hi Giovani, I would create an unnamed list and set the names after. Best, Ulrik On Fri, 4 Aug 2017 at 12:08 Giovanni Gherdovich <g.gherdovich at gmail.com> wrote: > 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 vari...
2017 Aug 04
2
define a list with names as variables
...kage. -- Sent from my phone. Please excuse my brevity. On August 4, 2017 3:14:44 AM PDT, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote: >Hi Giovani, > >I would create an unnamed list and set the names after. > >Best, >Ulrik > >On Fri, 4 Aug 2017 at 12:08 Giovanni Gherdovich ><g.gherdovich at gmail.com> >wrote: > >> 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 &q...
2017 Aug 04
0
define a list with names as variables
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 >
2017 Aug 04
0
define a list with names as variables
...use my brevity. > > On August 4, 2017 3:14:44 AM PDT, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote: >>Hi Giovani, >> >>I would create an unnamed list and set the names after. >> >>Best, >>Ulrik >> >>On Fri, 4 Aug 2017 at 12:08 Giovanni Gherdovich >><g.gherdovich at gmail.com> >>wrote: >> >>> 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 &g...
2017 Aug 14
0
recursive lapply and keeping track of data
...res) <- names(data) return(res) } } E.g., > new.data <- visit.level(data, integer()) Error in leaf.func(data, where) : Null data at c(3L, 2L) > data[[3]][2] $Madrid NULL Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Aug 14, 2017 at 11:43 AM, Giovanni Gherdovich < g.gherdovich at gmail.com> wrote: > 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 co...
2017 Aug 14
2
recursive lapply and keeping track of 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 vectors of numbers. The program takes this tree and replaces the vectors at the bottom by their