Here is a simpler, less clumsy version of my previous recursive R
solution that I sent you privately, which I'll also cc to the list
this time. It's now almost a one-liner.
To avoid problems with unused factor levels, I still prefer to have
character vectors not factors, as the data frame columns
On Mar 12, 2013, at 9:37 AM, Not To Miss wrote:
> Thanks. Is there any more elegant solution? What if I don't know how many
> levels of nesting ahead of time?
It's even worse than what you now offer as a potential complication. You did
not provide an example of a data object that would illustra
Thanks. Is there any more elegant solution? What if I don't know how many
levels of nesting ahead of time?
On Tue, Mar 12, 2013 at 8:51 AM, Greg Snow <538...@gmail.com> wrote:
> You can use the lapply or rapply functions on the resulting list to break
> each piece into a list itself, then apply
You can use the lapply or rapply functions on the resulting list to break
each piece into a list itself, then apply the lapply or rapply function to
those resulting lists, ...
On Mon, Mar 11, 2013 at 3:41 PM, Not To Miss wrote:
> Thanks. That's just an simple example - what if there are more co
Thanks. That's just an simple example - what if there are more columns and
more rows? Is there any easy way to create nested list?
Best,
Zech
On Mon, Mar 11, 2013 at 2:12 PM, MacQueen, Don wrote:
> You will have to decide what R data structure is a "tree structure". But
> maybe this will get y
Of course, R's recursive lists **are** trees.
(Some expert may rap my knuckles here, but ... close enough?)
-- Bert
On Mon, Mar 11, 2013 at 1:12 PM, MacQueen, Don wrote:
> You will have to decide what R data structure is a "tree structure". But
> maybe this will get you started:
>
>> foo <- dat
You will have to decide what R data structure is a "tree structure". But
maybe this will get you started:
> foo <- data.frame(x=c('A','A','B','B'), y=c('Ab','Ac','Ba','Bd'))
> split(foo$y, foo$x)
$A
[1] "Ab" "Ac"
$B
[1] "Ba" "Bd"
I suppose it is at least a little bit tree-like.
--
Don MacQuee
7 matches
Mail list logo