Creating hierarchy out of ‘n’ categorical columns

Here is an R snippet that helps converting a data frame with multiple columns into a hierarchical format.

Image 1_smallfont.png

In the below image, the right hand side table is the output achieved with the rootify function which uses the left hand side table as input. All we provide to rootify is the name of the .csv file which has the data table to be converted into the required format.

Image 2.png

The raw data as generated by rootify is valuable when it is further processed inside the arcdiagram/d3Network packages for easier and quicker data exploration. I will cover this in a future post.

Sanket

 
9
Kudos
 
9
Kudos

Now read this

Counting occurrences of digits(0-9) in a set of numbers

Last Friday, I had a conversation with a data scientist and he posed this programming question to me: “Count the number of occurrences of each of the digits 0-9 in a given set of numbers”. At first, the problem sounds simple, but given... Continue →