See the below example to understand how to create a tree from the data frame.
Use as.Node( ) to create tree from dataframe.
GNI2014$pathString <- paste("world",
sep = "/")
population <- as.Node(GNI2014)
print(population, "iso3", "population", "GNI", limit = 20)
The example is taken from here, check here for more information.