Message-ID: <5E1B812FAC2C4A49B3D99593B5A52191333F8C@PRDEXMBX-04.the-lab.llnl.gov>
Date: 2013-03-11T20:12:00Z
From: MacQueen, Don
Subject: how to convert a data.frame to tree structure object such as dendrogram
In-Reply-To: <CAAp=d8rT_V7WSJf8JTrKRd_UpiTMUzvJaY=UELf-=t-Shh4axQ@mail.gmail.com>
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 MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
On 3/10/13 9:19 PM, "Not To Miss" <not.to.miss at gmail.com> wrote:
>I have a data.frame object like:
>
>> data.frame(x=c('A','A','B','B'), y=c('Ab','Ac','Ba','Bd'))
> x y
>1 A Ab
>2 A Ac
>3 B Ba
>4 B Bd
>
>how could I create a tree structure object like this:
> |---Ab
> A---|
>_| |---Ac
> |
> | |---Ba
> B---|
> |---Bb
>
>Thanks,
>Zech
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.