See the below example to understand how to create a tree from the data frame.
Use as.Node( ) to create tree from dataframe.
library(treemap)
data(GNI2014)
head(GNI2014)
GNI2014$pathString <- paste("world",
GNI2014$continent,
GNI2014$country,
sep = "/")
population <- as.Node(GNI2014)
print(population, "iso3", "population", "GNI", limit = 20)
The example is taken from here, check here for more information.
https://cran.r-project.org/web/packages/data.tree/vignettes/data.tree.html#plotting