Hi Bert,
thank you for your suggestion. I'm sure it's a good one. But my intention in first place was to
learn about getting subsets of list nested in lists the fast way (and preferably also the easy way,
but that is only my laziness).
It seems this thread is getting a bit long and also lead
Alexander:
I'm not sure exactly what you want, so the following may be irrelevant...
BUT, noting that data frames ARE lists and IF what you have can then
be abstracted as lists of lists of lists of ... to various depths
AND IF what you want is just to pick out and combined all named
vectors (whic
Hello Gerrit, Gabor,
thank you for your suggestion.
Unfortunately unlist seems to be rather expensive. A short test with one
of my datasets gives 0.01s for an extraction based on my approach and
5.6s for unlist alone. The reason seems to be that unlist relies on
lapply internally and does so rec
Hello,
Matthew's hint is interesting:
Am 07.12.2010 19:16, schrieb Matthew Dowle:
> Hello Alex,
>
> Assuming it was just an inadequate example (since a data.frame would suffice
> in that case), did you know that a data.frames' columns do not have to be
> vectors but can be lists? I don't know
Hello Alex,
Assuming it was just an inadequate example (since a data.frame would suffice
in that case), did you know that a data.frames' columns do not have to be
vectors but can be lists? I don't know if that helps.
> DF = data.frame(a=1:3)
> DF$b = list(pi, 2:3, letters[1:5])
> DF
a
First, subset 'test' once, e.g.
testT <- test[1:3];
and then use sapply() on that, e.g.
val <- sapply(testT, FUN=function (x) { x$a })
Then you can avoid one level of function calls, by
val <- sapply(testT, FUN="[[", "a")
Second, there is some overhead in "[[", "$" etc. You can use
.subset2(
On Tue, Dec 7, 2010 at 12:12 PM, Alexander Senger
wrote:
> Hello Gerrit, Gabor,
>
>
> thank you for your suggestion.
>
> Unfortunately unlist seems to be rather expensive. A short test with one
> of my datasets gives 0.01s for an extraction based on my approach and
> 5.6s for unlist alone. The rea
the solution?
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of Alexander Senger
>> Sent: Tuesday, December 07, 2010
Hello, Alexander,
does
utest <- unlist(test)
utest[ names( utest) == "a"]
come close to what you need?
Hth,
Gerrit
On Tue, 7 Dec 2010, Alexander Senger wrote:
Hello,
my data is contained in nested lists (which seems not necessarily to be
the best approach). What I need is a fast way to
On Tue, Dec 7, 2010 at 9:47 AM, Alexander Senger
wrote:
> Hello,
>
>
> my data is contained in nested lists (which seems not necessarily to be
> the best approach). What I need is a fast way to get subsets from the data.
>
> An example:
>
> test <- list(list(a = 1, b = 2, c = 3), list(a = 4, b = 5
Hello,
my data is contained in nested lists (which seems not necessarily to be
the best approach). What I need is a fast way to get subsets from the data.
An example:
test <- list(list(a = 1, b = 2, c = 3), list(a = 4, b = 5, c = 6),
list(a = 7, b = 8, c = 9))
Now I would like to have all valu
11 matches
Mail list logo