Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
library(waffle)
library(viridis)
library(tidyverse)
data_frame(
country = c("Rest of World", "Canada*", "Brazil*", "South Korea", "Mexico",
"Russia", "Turkey", "Japan", "Taiwan", "Germany", "India"),
pct = c(22, 16, 13, 10, 9, 9, 7, 5, 4, 3, 2)
) %>%
mutate(country = sprintf("%s (%s%%)", country, pct)) %>%
waffle(
colors = c("gray70", viridis_pal(option = "plasma")(10))
) +
labs(
title = "U.S. Steel Imports — YTD 2017 Percent of Volume",
subtitle = "Ten nations account for ~80% of U.S. steel imports.",
caption = "Source: IHS Global Trade Atlas • YTD through September 2017\n* Canada & Brazil are not impacted by the proposed tariffs"
) +
theme_ipsum_ps() +
theme(legend.position = "top") +
theme(axis.text = element_blank()) +
theme(title = element_text(hjust=0.5)) +
theme(plot.title = element_text(hjust=0.5)) +
theme(plot.subtitle = element_text(hjust=0.5)) +
theme(plot.caption = element_text(hjust=1))
@mschnetzer

This comment has been minimized.

Copy link

@mschnetzer mschnetzer commented Mar 14, 2018

Hi,
this is concerning the error (list) object cannot be coerced to type ‘double’. This error even appears for your minimal example of the waffle package:

parts <- data.frame(
  names = LETTERS[1:4],
  vals = c(80, 30, 20, 10)
)
waffle(parts, rows=8)

Here is my sessionInfo():

Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.3

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] de_AT.UTF-8/de_AT.UTF-8/de_AT.UTF-8/C/de_AT.UTF-8/de_AT.UTF-8

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

other attached packages:
 [1] hrbrthemes_0.5.0  bindrcpp_0.2      forcats_0.3.0    
 [4] stringr_1.3.0     dplyr_0.7.4       purrr_0.2.4      
 [7] readr_1.1.1       tidyr_0.8.0       tibble_1.4.2     
[10] tidyverse_1.2.1   viridis_0.5.0     viridisLite_0.3.0
[13] waffle_0.7.0      ggplot2_2.2.1     devtools_1.13.5  

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.15       lubridate_1.7.3    lattice_0.20-35   
 [4] utf8_1.1.3         rprojroot_1.3-2    assertthat_0.2.0  
 [7] digest_0.6.15      psych_1.7.8        R6_2.2.2          
[10] cellranger_1.1.0   plyr_1.8.4         backports_1.1.2   
[13] evaluate_0.10.1    httr_1.3.1         pillar_1.2.1      
[16] rlang_0.2.0        lazyeval_0.2.1     curl_3.1          
[19] readxl_1.0.0       rstudioapi_0.7     extrafontdb_1.0   
[22] rmarkdown_1.9      labeling_0.3       extrafont_0.17    
[25] foreign_0.8-69     munsell_0.4.3      broom_0.4.3       
[28] compiler_3.4.3     modelr_0.1.1       pkgconfig_2.0.1   
[31] mnormt_1.5-5       htmltools_0.3.6    gridExtra_2.3     
[34] crayon_1.3.4       laeken_0.4.6       withr_2.1.1       
[37] MASS_7.3-49        grid_3.4.3         nlme_3.1-131.1    
[40] jsonlite_1.5       Rttf2pt1_1.3.6     gtable_0.2.0      
[43] git2r_0.21.0       magrittr_1.5       scales_0.5.0      
[46] cli_1.0.0          stringi_1.1.6      reshape2_1.4.3    
[49] xml2_1.2.0         boot_1.3-20        RColorBrewer_1.1-2
[52] tools_3.4.3        glue_1.2.0         hms_0.4.2         
[55] parallel_3.4.3     yaml_2.1.18        colorspace_1.3-2  
[58] rvest_0.3.2        memoise_1.1.0      knitr_1.20        
[61] bindr_0.1          haven_1.1.1   

Thanks for the help.
Matthias

@emilelatour

This comment has been minimized.

Copy link

@emilelatour emilelatour commented Mar 18, 2018

I had this issue also when I was using version 0.7.0 of the waffle package. When I installed the development version (0.8.0), this resolved the error.

devtools::install_github("hrbrmstr/waffle")
@mschnetzer

This comment has been minimized.

Copy link

@mschnetzer mschnetzer commented Mar 18, 2018

Thank you so much for your helpful answer. It worked perfectly!

@hrbrmstr

This comment has been minimized.

Copy link
Owner Author

@hrbrmstr hrbrmstr commented Apr 8, 2018

My IFTTT rule to notify abt gist comments magically started working again. Unfortunately I missed this. Issues on the repo may not get addressed immediately but they'll generally be seen earlier than gist comments (there's no built-in notification for gist comments)

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