Course treemap revisited

Thanks to the alertness of the reader(s) of this blog, the treemap of the previous post was found to be wrongly plotted. Contrary to what I wrote (albeit a bit fuzzy), the area of the rectangles did not correspond to the amount of courses. I don’t know what they corresponded to, if anything. The culprit was the factor levels of the School deptCode variable in the data. When I unfactorized it, the map plotted correctly.

The idea of the treemap is first to arrange the rectangles of the top hierarchy, School, in decreasing order by size, i.e. the amount of courses, starting from top left. Then, inside these rectangles, the rectangles of the sublevel, departments, are plotted. Again, in decreasing order, starting from top left.

Below is a snippet from an R session where I check the number of courses by School. From the dataframe coursedata.merged, I group data by School, calculate the sum of courses in each group, and store the values in a list vector. Then I sort the list in reverse order, i.e. biggest first.

> <- tapply(coursedata.merged$courses, coursedata.merged$school, FUN=sum)
1366 935 642 628 424 405 87

Here comes the revised map.

Revised treemap of Aalto courses by School and department