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 and data.table 1.9.5 problem #1216

Closed
ghost opened this issue Jul 9, 2015 · 3 comments
Closed

treemap and data.table 1.9.5 problem #1216

ghost opened this issue Jul 9, 2015 · 3 comments
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Jul 9, 2015

this gives an error in data.table 1.9.5 and whereas everything works under 1.9.4:

library(treemap)
data(business)
treemap(business,
index=c("NACE1", "NACE2", "NACE3"),
vSize="turnover",
type="index")

Error in [.data.table(datlist, , paste0("index", 1:(i - 1)), with = FALSE) :
column(s) not found: index4, index5

sessionInfo()

R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] treemap_2.3

loaded via a namespace (and not attached):
[1] igraph_1.0.0 Rcpp_0.11.6 magrittr_1.5 MASS_7.3-42 munsell_0.4.2 colorspace_1.2-6 xtable_1.7-4 gridBase_0.4-7 R6_2.0.1 stringr_1.0.0 plyr_1.8.3 tools_3.2.1
[13] grid_3.2.1 data.table_1.9.5 gtable_0.1.2 htmltools_0.2.6 digest_0.6.8 shiny_0.12.1 RColorBrewer_1.1-2 reshape2_1.4.1 ggplot2_1.0.1 mime_0.3 stringi_0.5-2 scales_0.2.5
[25] httpuv_1.3.2 chron_2.3-47 proto_0.3-10

@jangorecki
Copy link
Member

You should let the treemap maintainer @mtennekes know, the error occurs in tmGenerateRect.R#L58

@mtennekes
Copy link

It seems to be a bug in data.table:

dt <- data.table(index1=1:10, index2=10:1, index3=1, s=4, i=24)

i <- 2
dt[, paste0("index", 1:i), with=FALSE]
# Error in `[.data.table`(dt, , paste0("index", 1:i), with = FALSE) : 
# column(s) not found: index4, index5

dt[, paste0("index", 1:2), with=FALSE]
# No problems

ii <- 2
dt[, paste0("index", 1:ii), with=FALSE]
# Also no problems

@jangorecki
Copy link
Member

slightly simplified:

library(data.table)
i<-1
data.table(a1=1)[, paste0("a",i), with=FALSE]
#    a1
# 1:  1
data.table(a1=1, i=2)[, paste0("a",i), with=FALSE]
# Error in `[.data.table`(data.table(a1 = 1, i = 2), , paste0("a", i), with = FALSE) : 
#   column(s) not found: a2

Looks like a scoping issue with with=F and variable/column name collision.

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

No branches or pull requests

3 participants