3

I am relatively new to R and am trying to learn through some basic courses and trying to solve some problems that I face.

I searched through the forum and google and found what I thought were solutions to my problem but could not get any to work. I have tried the zoo and igraph libraries as well as a few others.

I have a data frame with four columns and about 2k rows. Each column is filled with factors and contain a family, a class, a subclass, and an outcome (binary converted to factor). Hierarchically, they go from broadest category to most detailed. I am trying to create a hierarchy of each "family" showing it's descendants and the counts at each level for the whole data frame. Say family A has 30 rows throughout the data frame. The top box would have "A" with the count of "30". Beneath family "A" we may have 20 in class "A" and 10 in class "B", etc.

Can anyone provide guidance as to what package(s) I can use to accomplish this? From there I can likely find some tutorials. It seems as though it should be a straightforward problem but it escapes me.

Thanks!

Bill

* EDIT *

user1362215 ... as I mentioned "I searched through the forum and google and found what ..." I looked at that package and it was one of the ones I thought was what I needed. Those CRAN docs are difficult for me to understand at times. I have seen that it is the "definitive" source but I tend to find other resources more understandable for me at my level. I have programmed in php, python, and several other languages but R is, for some reason, the most difficult for me to get my head around.

MrFlick ... thanks for the link ... here are 10 rows from a sample data frame ...

> test
   family class subclass outcome
1       A     A        B       0
2       A     A        B       1
3       A     B        A       0
4       B     C        C       0
5       B     B        B       1
6       B     A        B       0
7       C     D        C       1
8       C     C        C       1
9       A     A        A       1
10      B     D        A       0
...
...
...

And here is the link to what I am trying to accomplish (image only has three levels, however, the dataframe has four) ... http://imgur.com/zocWU9d

In the image diagram, the family column will be the first horizontal level, class the second, subclass the third (omitted from diagram), and outcome the last. I hope this makes it more clear. Thanks to all!

  • 3
    It would be easier to help you if you could provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It shouldn't be all 2k rows, just something small and representative. If you know of plot that kind of looks like what you want to make, it would be useful to link to it or mock up a simple sketch so we know exactly what you want. – MrFlick May 07 '15 at 00:40
  • 2
    Whenever you want to do something in R, if you don't know how to do it, try doing a google search for "[what I want to do] cran". Doing so with flow charts gave this as the first result: http://cran.r-project.org/web/packages/diagram/vignettes/diagram.pdf – Max Candocia May 07 '15 at 00:47
  • 2
    The link I provided should give tips on creating reproducible data. You don't have enough rep to post a pic, but if you upload to imgur.com and provide a link, someone else can edit it into your question. You should be able to edit your question to address issues brought up in the comments. – MrFlick May 07 '15 at 00:47

0 Answers0