2
votes

I am trying to plot a treemap. I have installed all the necessary packages:

install.packages("ggplot2")

install.packages("reshape2")

install.packages("plyr")

install.packages("devtools")

I am running the first part of my code fine:

 library(treemapify)
 library(devtools)
 treeMapCoordinates <- treemapify(df,
                             area = "MMR_Count",
                             fill = "MMR_Count",
                             label = "Business",
                             group = "Year")

here is where the error occurs:

treeMapPlot <- ggplotify(treeMapCoordinates)

This is the error message:

Error in ggplotify(treeMapCoordinates) : could not find function "ggplotify"

Where am I making a mistake?

1
Search google, the first result you get is the documentation for ggplotify which shows it is a function from the package treemapify. rdocumentation.org/packages/treemapify/versions/0.2.2/topics/… - Jack Brookes
@JackBrookes I have installed Treemapify, that is the question why it is not calling - Ibo
github.com/wilkox/treemapify/… , so try using geom_treemap - user20650
@user20650 yes, treemapify is depricated and geom_treemap is the new function, I got it to work, thanks! - Ibo

1 Answers

1
votes
    ggplot2::ggplot(treeMapCoordinates, ggplot2::aes(area = MMR_Count, fill = MMR_Count)) 
+ geom_treemap()

could this work? Its basically an example of geom_treemap function documentation with your "area" and "fill" name.

P.S. ggplotify doesn't work for me too.