ecohealthalliance / predict-ma-reports

0 stars 0 forks source link

'Error: unable to find an inherited method for function 'select' for signature '"eidith_tbl"'' #15

Closed soride closed 4 years ago

soride commented 4 years ago

I got through most of the readme instructions but hit this block below (which may just be may be something simple as I'm not staying up with the latest in R - is it perhaps masking the select function?)

//r

source('make.R')

processing file: report-template.Rmd |... | 3% inline R code fragments

|....... | 5% label: setup (with options) List of 3 $ include: logi FALSE $ message: logi FALSE $ warning: logi FALSE


Note: As of version 1.0.0, cowplot does not change the default ggplot2 theme anymore. To recover the previous behavior, execute: theme_set(theme_cowplot())


Attaching package: 'glue'

The following object is masked from 'package:dplyr':

collapse

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

group_rows

Loading required package: sp

Attaching package: 'raster'

The following object is masked from 'package:glue':

trim

The following object is masked from 'package:dplyr':

select

The following object is masked from 'package:tidyr':

extract

|.......... | 8% inline R code fragments

|.............. | 11% label: read-data (with options) List of 1 $ include: logi FALSE

Quitting from lines 58-166 (report-template.Rmd)

Error: unable to find an inherited method for function 'select' for signature '"eidith_tbl"' <simpleError in (function (classes, fdef, mtable) { methods <- .findInheritedMethods(classes, fdef, mtable) if (length(methods) == 1L) return(methods[[1L]]) else if (length(methods) == 0L) { cnames <- paste0("\"", vapply(classes, as.character, ""), "\"", collapse = ", ") stop(gettextf("unable to find an inherited method for function %s for signature %s", sQuote(fdef@generic), sQuote(cnames)), domain = NA) } else stop("Internal error in finding inherited methods; didn't return a unique method", domain = NA)})(list("eidith_tbl"), new("standardGeneric", .Data = function (x, ...) standardGeneric("select"), generic = structure("select", package = "raster"), package = "raster", group = list(), valueClass = character(0), signature = "x", default = NULL, skeleton = (function (x, ...) stop("invalid call in method dispatch to 'select' (no default method)", domain = NA))(x, ...)), ): unable to find an inherited method for function 'select' for signature '"eidith_tbl"'> Error in eval(ei, envir) : Error building Vietnam //r

emmamendelsohn commented 4 years ago

Hi @soride! I think you're right that the select function is masked. This happens when more than one package with a select function is loaded (in this case we wanted to use the dplyr version but it's defaulting to another package). A simple R session restart before running the make.R file should fix this. Let me know if this doesn't work.

soride commented 4 years ago

Thanks Emma! I'm now getting an error 'The rnaturalearthhires package needs to be installed.' I restarted and then manually used library() to make sure all the packages were loaded. BTW, the iNext package did not load because CRAN version was not compatible with R version 3.6.2 and was causing error so downloaded it directly from here https://github.com/JohnsonHsieh/iNEXT.

emmamendelsohn commented 4 years ago

I just made a few changes that should address these issues. Try pulling the latest version and running devtools::install_deps() again.

Note the rnaturalearthhires download is fairly slow at the moment (~10 minutes). The connection seems to be intermittent (which may have been why your download failed last time), so try again if you get an error.

Thanks for working through this! It can be tricky getting all the dependencies right. Let me know if this works or if anything else pops up.

soride commented 4 years ago

You are too kind and patient - thanks. I ran install_deps twice, the first time it looked like this:

> devtools::install_deps(upgrade = "always")
iNEXT      (1db6daa5f... -> e31d091cb...) [GitHub]
NA         (NA           -> NA          ) [URL]
sf         (0.8-0        -> 0.8-1       ) [CRAN]
tidyselect (0.2.5        -> 1.0.0       ) [CRAN]
Skipping 1 packages not available: rnaturalearthhires
Downloading package from url: http://packages.ropensci.org/job/rnaturalearthhires/ws/*zip*/rnaturalearthhires.zip

✓  checking for file ‘/private/var/folders/ns/p1nw71wn1dn9vlb6lc_4kpgm0000gn/T/Rtmp2ypzK2/remotes6f912a62ef06/rnaturalearthhires/DESCRIPTION’ (631ms)
─  preparing ‘rnaturalearthhires’:
✓  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘rnaturalearthhires_0.2.0.tar.gz’ (6.2s)

* installing *source* package ‘rnaturalearthhires’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rnaturalearthhires)
Installing 3 packages: rnaturalearthhires, sf, tidyselect
Error: (converted from warning) package ‘rnaturalearthhires’ is not available (for R version 3.6.2)

But rnaturalearthhires still wasn't loaded. I reran:

> devtools::install_deps(upgrade = "always")
iNEXT      (1db6daa5f... -> e31d091cb...) [GitHub]
NA         (NA           -> NA          ) [URL]
sf         (0.8-0        -> 0.8-1       ) [CRAN]
tidyselect (0.2.5        -> 1.0.0       ) [CRAN]
Downloading package from url: http://packages.ropensci.org/job/rnaturalearthhires/ws/*zip*/rnaturalearthhires.zip

✓  checking for file ‘/private/var/folders/ns/p1nw71wn1dn9vlb6lc_4kpgm0000gn/T/Rtmp2ypzK2/remotes6f91174fe33f/rnaturalearthhires/DESCRIPTION’ (490ms)
─  preparing ‘rnaturalearthhires’:
✓  checking DESCRIPTION meta-information ... 
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘rnaturalearthhires_0.2.0.tar.gz’ (5.3s)

* installing *source* package ‘rnaturalearthhires’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (rnaturalearthhires)
Installing 2 packages: sf, tidyselect

  There are binary versions available but the source versions are later:
           binary source needs_compilation
sf          0.8-0  0.8-1              TRUE
tidyselect  0.2.5  1.0.0              TRUE

Do you want to install from sources the packages which need compilation? (Yes/no/cancel) Yes
installing the source packages ‘sf’, ‘tidyselect’

trying URL 'https://cran.rstudio.com/src/contrib/sf_0.8-1.tar.gz'
Content type 'application/x-gzip' length 8469173 bytes (8.1 MB)
==================================================
downloaded 8.1 MB

trying URL 'https://cran.rstudio.com/src/contrib/tidyselect_1.0.0.tar.gz'
Content type 'application/x-gzip' length 151161 bytes (147 KB)
==================================================
downloaded 147 KB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: clang
configure: CXX: clang++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/sf’
Error in i.p(...) : 
  (converted from warning) installation of package ‘sf’ had non-zero exit status

Still did not install so then I went ahead and did this:

> install.packages("rnaturalearthhires",
+                  repos = "http://packages.ropensci.org",
+                  type = "source")

And it finally loaded. I then marched through the rest of the commands.

source("scripts/generate_mammal_country_lookup.R")

Resulted in this error -

Error: sum(lookup.table$binomial %in% unique(mz$species)) not equal to nrow(lookup.table)

But I ignored it... as I assumed we don't have any IUCN/HP3 name reconciliation. Otherwise it ran with this last 'warning message' below!!! Sharing just in case, but super tickled this all worked finally. Thank you!!

Output created: outputs/Vietnam-ma-report.html
Warning messages:
1: In colors(.) :
  Some values were outside the color scale and will be treated as NA
2: filter_() is deprecated. 
Please use filter() instead

The 'programming' vignette or the tidyeval book can help you
to program with filter() : https://tidyeval.tidyverse.org
This warning is displayed once per session. 
3: group_by_() is deprecated. 
Please use group_by() instead

The 'programming' vignette or the tidyeval book can help you
to program with group_by() : https://tidyeval.tidyverse.org
This warning is displayed once per session. 
4: In Fun(x, q) :
  Insufficient data to provide reliable estimators and associated s.e.
5: In Fun(x, q) :
  Insufficient data to provide reliable estimators and associated s.e.
emmamendelsohn commented 4 years ago

Great! Glad you got it working with install.packages("rnaturalearthhires"...). That didn't work for me this morning.

As for the error message--yes, that was something we included to alert to IUCN/HP3 name reconciliation issues. It probably should have been a warning instead. You may want to comment it out and source the script again as the error message would have aborted the run.

All the warnings look "normal" to me. But let me know if you got any wonky results.