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

Method for 'grobify' missing #6

Closed
fpmassam opened this issue May 2, 2018 · 7 comments
Closed

Method for 'grobify' missing #6

fpmassam opened this issue May 2, 2018 · 7 comments
Assignees
Labels

Comments

@fpmassam
Copy link

fpmassam commented May 2, 2018

I am running your sample code:

set.seed(1234)
d <- data.frame(x=rnorm(50), y=rnorm(50), 
                country=sample(c("ar","fr", "nz", "gb", "es", "ca"), 50, TRUE), 
                stringsAsFactors = FALSE)
ggplot(d, aes(x=x, y=y, country=country, size=x)) + 
  geom_flag() + 
  scale_country() +
  scale_size(range = c(0, 15))

but I get this error:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘grobify’ for signature ‘"NULL"’

My session info:

R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

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

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

other attached packages:
[1] ggplot2_2.2.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.15 xml2_1.1.1 magrittr_1.5 munsell_0.4.3 uuid_0.1-2 colorspace_1.3-2
[7] R6_2.2.2 jpeg_0.1-8 rlang_0.1.6 grImport2_0.1-4 plyr_1.8.4 tools_3.4.3
[13] grid_3.4.3 gtable_0.2.0 png_0.1-7 rvg_0.1.7 R.oo_1.21.0 ggiraph_0.4.2
[19] ggflags_0.0.2 htmltools_0.3.6 lazyeval_0.2.0 digest_0.6.12 tibble_1.4.2 zip_1.0.0
[25] officer_0.2.0 base64enc_0.1-3 htmlwidgets_0.9 R.utils_2.6.0 ggrepel_0.7.0 labeling_0.3
[31] compiler_3.4.3 pillar_1.1.0 gdtools_0.1.6 scales_0.5.0 R.methodsS3_1.7.1 XML_3.98-1.9

@jimjam-slam
Copy link
Owner

Hi @fpmassam! Sorry about that. I won't be able to look into this until weekend, I'm afraid!

@jimjam-slam jimjam-slam self-assigned this May 3, 2018
@jimjam-slam jimjam-slam added the bug label May 3, 2018
@fpmassam
Copy link
Author

fpmassam commented May 3, 2018

@Rensa Take your time :D

@jimjam-slam
Copy link
Owner

Hey @fpmassam, I'm having trouble reproducing this problem, but I notice in your sessionInfo() that ggflags is "loaded via a namespace (and not attached)" , rather than being an "other attached package" as it is in my setup.

Is it possible that you haven't loaded ggflags using library(ggflags) before running the sample code? I haven't modified since I forked this package, but it definitely ought to be there! 😅

@gustavo-jose
Copy link

gustavo-jose commented Oct 3, 2019

Hey dear @fpmassam and @Rensa,

were you abe to find a solution for this error? I just happen to have stumble across it.
You can can find the code below together with my session info as well as the needed data attached.
For all regions I am able to build the nice figures with your beautiful flags but when I get to Europe, I get the same exact error as @fpmassam.
I would be extremely grateful for some advise :) Thanks!

CPI_2018.xlsx

# Europe 

CPI_2018_EUR <- dplyr::filter(.data = CPI_2018, region_name == 'Europe')

ggplot(data = CPI_2018_EUR, aes(x = reorder(ISO3, CPI_SCORE_2018),
                                y = CPI_SCORE_2018)) +
  geom_bar(stat = "identity") +
  coord_flip() +
  xlab("Country Code ISO3") +
  ylab("CPI Score 2018") +
  geom_flag(y = -1, aes(country = lower_case_iso_2), size = 4)

Session info -------------------------------------------------------------------
setting value
version R version 3.6.1 (2019-07-05)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate German_Germany.1252
ctype German_Germany.1252
tz Europe/Berlin
date 2019-10-03

Packages -----------------------------------------------------------------------
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)
backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.6.0)
broom 0.5.2 2019-04-07 [1] CRAN (R 3.6.1)
callr 3.3.2 2019-09-22 [1] CRAN (R 3.6.1)
cellranger 1.1.0 2016-07-27 [1] CRAN (R 3.6.1)
cli 1.1.0 2019-03-19 [1] CRAN (R 3.6.1)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.1)
crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)
desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)
devtools * 2.2.1 2019-09-24 [1] CRAN (R 3.6.1)
digest 0.6.21 2019-09-20 [1] CRAN (R 3.6.1)
dplyr * 0.8.3 2019-07-04 [1] CRAN (R 3.6.1)
ellipsis 0.3.0 2019-09-20 [1] CRAN (R 3.6.1)
forcats * 0.4.0 2019-02-17 [1] CRAN (R 3.6.1)
fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.1)
generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.1)
ggflags * 0.0.2 2019-09-26 [1] Github (401494a)
ggplot2 * 3.2.1 2019-08-10 [1] CRAN (R 3.6.1)
glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1)
grImport2 0.1-5 2019-05-06 [1] CRAN (R 3.6.1)
gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.1)
haven 2.1.1 2019-07-04 [1] CRAN (R 3.6.1)
hms 0.5.1 2019-08-23 [1] CRAN (R 3.6.1)
httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.1)
jpeg 0.1-8 2014-01-23 [1] CRAN (R 3.6.0)
jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.1)
labeling 0.3 2014-08-23 [1] CRAN (R 3.6.0)
lattice 0.20-38 2018-11-04 [2] CRAN (R 3.6.1)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.6.1)
lifecycle 0.1.0 2019-08-01 [1] CRAN (R 3.6.1)
lubridate 1.7.4 2018-04-11 [1] CRAN (R 3.6.1)
magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)
memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.1)
modelr 0.1.5 2019-08-08 [1] CRAN (R 3.6.1)
munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.1)
nlme 3.1-140 2019-05-12 [2] CRAN (R 3.6.1)
pillar 1.4.2 2019-06-29 [1] CRAN (R 3.6.1)
pkgbuild 1.0.5 2019-08-26 [1] CRAN (R 3.6.1)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.6.1)
png 0.1-7 2013-12-03 [1] CRAN (R 3.6.0)
prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.1)
processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.1)
purrr * 0.3.2 2019-03-15 [1] CRAN (R 3.6.1)
R6 2.4.0 2019-02-14 [1] CRAN (R 3.6.1)
Rcpp 1.0.2 2019-07-25 [1] CRAN (R 3.6.1)
readr * 1.3.1 2018-12-21 [1] CRAN (R 3.6.1)
readxl * 1.3.1 2019-03-13 [1] CRAN (R 3.6.1)
remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1)
rlang 0.4.0 2019-06-25 [1] CRAN (R 3.6.1)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)
rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.1)
rvest 0.3.4 2019-05-15 [1] CRAN (R 3.6.1)
scales 1.0.0 2018-08-09 [1] CRAN (R 3.6.1)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1)
stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 3.6.1)
testthat 2.2.1 2019-07-25 [1] CRAN (R 3.6.1)
tibble * 2.1.3 2019-06-06 [1] CRAN (R 3.6.1)
tidyr * 1.0.0 2019-09-11 [1] CRAN (R 3.6.1)
tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.1)
tidyverse * 1.2.1 2017-11-14 [1] CRAN (R 3.6.1)
usethis * 1.5.1 2019-07-04 [1] CRAN (R 3.6.1)
vctrs 0.2.0 2019-07-05 [1] CRAN (R 3.6.1)
withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1)
XML 3.98-1.20 2019-06-06 [1] CRAN (R 3.6.0)
xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.1)
zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.1)

[1] C:/Users/Gustavo/Documents/R/win-library/3.6
[2] C:/Program Files/R/R-3.6.1/library

@jimjam-slam
Copy link
Owner

Hi @gustavo-jose! Thanks very much for the detailed info 😄

Are you able to post the column of European country codes in your data as plain text here? I just want to quickly check against this render of all the flags to see if there are any countries that might be missing from our database (because an invalid country code would trigger this error... I probably need to add some explicit checking in order to give more informative errors!).

image

@gustavo-jose
Copy link

Dear @Rensa,sorry for the unnecesary surplus information (pretty new into this) 🙈.
I have find the country triggering the error. For an unknown reason my dataset had an outdated iso2 for Serbia (cs instead of rs).
Sorry for bothering, as you wrote, I wasn't able to infer that this might be the issue out of the error text 😀 Thanks for the advise!

All the best for you,

Gustavo

@jimjam-slam
Copy link
Owner

That's okay! I'll open a new issue for improving the error text 😄

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

No branches or pull requests

3 participants