Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

treemap(data.table)? #9

Closed
rlzijdeman opened this issue Mar 4, 2014 · 1 comment
Closed

treemap(data.table)? #9

rlzijdeman opened this issue Mar 4, 2014 · 1 comment

Comments

@rlzijdeman
Copy link

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")

@mtennekes
Copy link
Owner

Fixed! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants