You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
It's clearly stated in the documentation that the object to be used for the treemap should be a dataframe. Technically data.table's are dataframes, but they don't seem to work well with the treemap syntax, although from some errors it appears that treemap uses data.table internally (at least in the case of itreemap). While the obvious solution is of course to revert the data.table to a data.frame, it seems like a bug or hidden feature.
Code to illustrate this point (replace // with #):
data(GNI2010)
library(data.table)
// works:
treemap(GNI2010,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value")
// GNI2010 as data.table doesn't work:
GNI2010.dt <- data.table(GNI2010)
treemap(GNI2010.dt,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value")
// Error in setnames(dtfDT, old = names(dtfDT), new = c(indexList, "s", "c", :
// x is not a data.table or data.frame
// reverting back to data.frame works:
GNI2010.dt.df <- as.data.frame(GNI2010.dt)
treemap(GNI2010.dt.df,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value")
The text was updated successfully, but these errors were encountered:
Hi,
It's clearly stated in the documentation that the object to be used for the treemap should be a dataframe. Technically data.table's are dataframes, but they don't seem to work well with the treemap syntax, although from some errors it appears that treemap uses data.table internally (at least in the case of itreemap). While the obvious solution is of course to revert the data.table to a data.frame, it seems like a bug or hidden feature.
Code to illustrate this point (replace // with #):
data(GNI2010)
library(data.table)
// works:
treemap(GNI2010,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value")
// GNI2010 as data.table doesn't work:
GNI2010.dt <- data.table(GNI2010)
treemap(GNI2010.dt,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value")
// Error in setnames(dtfDT, old = names(dtfDT), new = c(indexList, "s", "c", :
// x is not a data.table or data.frame
// reverting back to data.frame works:
GNI2010.dt.df <- as.data.frame(GNI2010.dt)
treemap(GNI2010.dt.df,
index=c("continent", "iso3"),
vSize="population",
vColor="GNI",
type="value")
The text was updated successfully, but these errors were encountered: