Closed jonathan-g closed 4 years ago
Thanks for the report. I'm afraid I'm a bit stumped by this one – I don't get this error on my computer with the same version of R and of the package:
library(tidyverse)
library(treemapify)
nations <- tibble(country=c('USA','Japan','EU','Canada','Australia',
'Other Enthusiastic', 'Brazil', 'China','India',
'Indonesia','Other Reluctant',
'Small Islands', 'Other Vulnerable',
'Russia', 'Other Exporters'),
type = c(rep_len('Enthusiastic', 6), rep_len('Reluctant',5),
rep_len('Vulnerable',2), rep_len('Exporters',2)),
emissions = c(17.3, 3.9, 14.2, 2.0, 1.7, 0.6,
5.10001, 20.5, 5.4, 1.7, 5.1,
0.9, 7.3,
6.1, 8.1))
nations <- nations %>%
mutate(type = ordered(type, levels = c('Enthusiastic', 'Reluctant',
'Exporters', 'Vulnerable')),
country = ordered(country, levels = country)) %>%
arrange(type, desc(emissions), country)
treemapify(nations, area = "emissions")
#> # A tibble: 15 x 6
#> country type ymax ymin xmin xmax
#> <ord> <ord> <dbl> <dbl> <dbl> <dbl>
#> 1 China Reluctant 0.542 0 0 0.378
#> 2 USA Enthusiastic 1 0.542 0 0.378
#> 3 EU Enthusiastic 0.359 0 0.378 0.774
#> 4 Other Exporters Exporters 0.359 0 0.774 1
#> 5 Other Vulnerable Vulnerable 0.575 0.359 0.378 0.717
#> 6 Russia Exporters 0.575 0.359 0.717 1
#> 7 India Reluctant 0.794 0.575 0.378 0.626
#> 8 Brazil Reluctant 1 0.794 0.378 0.626
#> 9 Other Reluctant Reluctant 0.816 0.575 0.626 0.838
#> 10 Japan Enthusiastic 0.816 0.575 0.838 1
#> 11 Canada Enthusiastic 1 0.816 0.626 0.734
#> 12 Australia Enthusiastic 0.908 0.816 0.734 0.919
#> 13 Indonesia Reluctant 1 0.908 0.734 0.919
#> 14 Small Islands Vulnerable 0.926 0.816 0.919 1
#> 15 Other Enthusiastic Enthusiastic 1 0.926 0.919 1
treemapify(nations, area = "emissions", subgroup = "type")
#> # A tibble: 15 x 6
#> country type ymax ymin xmin xmax
#> <ord> <ord> <dbl> <dbl> <dbl> <dbl>
#> 1 USA Enthusiastic 0.512 0 0 0.338
#> 2 EU Enthusiastic 0.325 0 0.338 0.776
#> 3 Japan Enthusiastic 0.512 0.325 0.338 0.546
#> 4 Canada Enthusiastic 0.512 0.325 0.546 0.653
#> 5 Australia Enthusiastic 0.463 0.325 0.653 0.776
#> 6 Other Enthusiastic Enthusiastic 0.512 0.463 0.653 0.776
#> 7 China Reluctant 1 0.512 0 0.421
#> 8 India Reluctant 0.808 0.512 0.421 0.603
#> 9 Brazil Reluctant 0.808 0.512 0.603 0.776
#> 10 Other Reluctant Reluctant 1 0.808 0.421 0.687
#> 11 Indonesia Reluctant 1 0.808 0.687 0.776
#> 12 Other Exporters Exporters 0.362 0 0.776 1
#> 13 Russia Exporters 0.634 0.362 0.776 1
#> 14 Other Vulnerable Vulnerable 0.960 0.634 0.776 1
#> 15 Small Islands Vulnerable 1.00 0.960 0.776 1
sessionInfo()
#> R version 3.6.3 (2020-02-29)
#> Platform: x86_64-apple-darwin19.3.0 (64-bit)
#> Running under: macOS Catalina 10.15.4
#>
#> Matrix products: default
#> BLAS/LAPACK: /usr/local/Cellar/openblas/0.3.9/lib/libopenblasp-r0.3.9.dylib
#>
#> locale:
#> [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] treemapify_2.5.3.9001 forcats_0.5.0 stringr_1.4.0
#> [4] dplyr_0.8.5 purrr_0.3.3 readr_1.3.1
#> [7] tidyr_1.0.2 tibble_3.0.1 ggplot2_3.3.0
#> [10] tidyverse_1.3.0 nvimcom_0.9-83
#>
#> loaded via a namespace (and not attached):
#> [1] tidyselect_1.0.0 xfun_0.12 haven_2.2.0
#> [4] lattice_0.20-38 colorspace_1.4-1 vctrs_0.2.4
#> [7] generics_0.0.2 htmltools_0.4.0 yaml_2.2.1
#> [10] utf8_1.1.4 rlang_0.4.5 pillar_1.4.3
#> [13] glue_1.4.0 withr_2.2.0 DBI_1.1.0
#> [16] dbplyr_1.4.2 modelr_0.1.6 readxl_1.3.1
#> [19] lifecycle_0.2.0 ggfittext_0.8.1.9002 munsell_0.5.0
#> [22] gtable_0.3.0 cellranger_1.1.0 rvest_0.3.5
#> [25] evaluate_0.14 knitr_1.28 fansi_0.4.1
#> [28] highr_0.8 broom_0.5.5 Rcpp_1.0.4.6
#> [31] scales_1.1.0 backports_1.1.6 jsonlite_1.6.1
#> [34] fs_1.3.2 hms_0.5.3 digest_0.6.25
#> [37] stringi_1.4.6 grid_3.6.3 cli_2.0.2
#> [40] tools_3.6.3 magrittr_1.5 crayon_1.3.4
#> [43] pkgconfig_2.0.3 ellipsis_0.3.0 xml2_1.2.2
#> [46] reprex_0.3.0 lubridate_1.7.4 assertthat_0.2.1
#> [49] rmarkdown_2.1 httr_1.4.1 R6_2.4.1
#> [52] nlme_3.1-144 compiler_3.6.3
Created on 2020-04-25 by the reprex package (v0.3.0)
As you pointed out the error is cryptic so I don't even know where to start looking for a potential cause. I assume it's a subsetting operation somewhere. Have you had any progress on this since you first posted it?
I've upgraded to R 4.0.0 and I no longer get this error. I will close the issue since it is no longer a problem for me.
See the following reprex: If I render the data frame with
treemapify
without subgroups it works fine, but if I render it with a subgroup, I get a very unclear error message "Error:
imust have one dimension, not 2.
"Created on 2020-04-13 by the reprex package (v0.3.0)
Here is my session info. I get the same error with the CRAN version, but I installed the latest GitHub version to be sure the bug hadn't been fixed in the development verion.