ropensci / c14bazAAR

R Package - Download and Prepare C14 Dates from Different Source Databases
https://docs.ropensci.org/c14bazAAR
GNU General Public License v2.0
30 stars 12 forks source link

devtools::check() and devtools::check(vignettes = F) errors #159

Closed zoometh closed 1 year ago

zoometh commented 1 year ago

Working on the get_neonet() function. I devtools::check() locally (my clone)

E  creating vignettes (23.9s)
   --- re-building 'simple_plotting.Rmd' using rmarkdown
   Warning: Removed 4550 row(s) containing missing values (geom_path).
   Quitting from lines 185-186 (simple_plotting.Rmd) 
   Error: processing vignette 'simple_plotting.Rmd' failed with diagnostics:
   there is no package called 'rnaturalearth'
   --- failed re-building 'simple_plotting.Rmd'

   SUMMARY: processing the following file failed:
     'simple_plotting.Rmd'

   Error: Vignette re-building failed.
   Execution halted
E  checking examples (4.4s)
   Running examples in 'c14bazAAR-Ex.R' failed
   The error most likely occurred in:

   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
   > ### Name: c14_date_list
   > ### Title: *c14_date_list*
   > ### Aliases: c14_date_list as.c14_date_list is.c14_date_list
   > ###   format.c14_date_list print.c14_date_list plot.c14_date_list
   > 
   > ### ** Examples
   > 
   > as.c14_date_list(data.frame(c14age = c(2000, 2500), c14std = c(30, 35)))
    Radiocarbon date list
    dates: 2
    uncalBP: 2500 - 2000 

   # A data frame: 2 x 2
     c14age c14std
      <int>  <int>
   1   2000     30
   2   2500     35
   > is.c14_date_list(5) # FALSE
   [1] FALSE
   > is.c14_date_list(example_c14_date_list) # TRUE
   [1] TRUE
   > 
   > print(example_c14_date_list)
    Radiocarbon date list
    dates: 9
    sites: 4
    countries: 5
    uncalBP: 9000 - 1000 

   # A data frame: 9 x 19
     sourcedb method labnr c14age c14std c13val site   sitetype     feature period 
     <chr>    <chr>  <chr>  <int>  <int>  <dbl> <chr>  <chr>        <chr>   <chr>  
   1 A        Conv   lab-1   1000     20    -15 Site A Burial mound Grave 1 <NA>   
   2 A        Conv   lab-2   2000     30    -20 Site A <NA>         Grave 2 Bronze~
   3 A        AMS    lab-3   3000     40    -25 Site B settlement   <NA>    Bronze~
   4 B        <NA>   lab-4   4000     50    -15 Site B settlement   House 5 Late N~
   5 B        AMS    lab-5   5000     50    -20 Site C settlement   <NA>    <NA>   
   6 B        AMS    lab-6   6000     60    -25 Site C settlement   Oven 4  Early ~
   7 C        AMS    lab-7   7000     70    -15 Site D Camp         Hut 2   Mesoli~
   8 C        AMS    lab-8   8000     80    -20 Site D Camp         Hut 2   Mesoli~
   9 C        AMS    lab-9   9000     90    -25 Site D Camp         Hut 3   Mesoli~
   # ... with 9 more variables: culture <chr>, material <chr>, species <chr>,
   #   region <chr>, country <chr>, lat <dbl>, lon <dbl>, shortref <chr>,
   #   comment <chr>
   > plot(example_c14_date_list)
   Error: R packages globe needed for this function to work. Please install with install.packages(c('globe'))
   Execution halted
E  checking examples with --run-donttest (4.4s)
   Running examples in 'c14bazAAR-Ex.R' failed
   The error most likely occurred in:

   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
   > ### Name: c14_date_list
   > ### Title: *c14_date_list*
   > ### Aliases: c14_date_list as.c14_date_list is.c14_date_list
   > ###   format.c14_date_list print.c14_date_list plot.c14_date_list
   > 
   > ### ** Examples
   > 
   > as.c14_date_list(data.frame(c14age = c(2000, 2500), c14std = c(30, 35)))
    Radiocarbon date list
    dates: 2
    uncalBP: 2500 - 2000 

   # A data frame: 2 x 2
     c14age c14std
      <int>  <int>
   1   2000     30
   2   2500     35
   > is.c14_date_list(5) # FALSE
   [1] FALSE
   > is.c14_date_list(example_c14_date_list) # TRUE
   [1] TRUE
   > 
   > print(example_c14_date_list)
    Radiocarbon date list
    dates: 9
    sites: 4
    countries: 5
    uncalBP: 9000 - 1000 

   # A data frame: 9 x 19
     sourcedb method labnr c14age c14std c13val site   sitetype     feature period 
     <chr>    <chr>  <chr>  <int>  <int>  <dbl> <chr>  <chr>        <chr>   <chr>  
   1 A        Conv   lab-1   1000     20    -15 Site A Burial mound Grave 1 <NA>   
   2 A        Conv   lab-2   2000     30    -20 Site A <NA>         Grave 2 Bronze~
   3 A        AMS    lab-3   3000     40    -25 Site B settlement   <NA>    Bronze~
   4 B        <NA>   lab-4   4000     50    -15 Site B settlement   House 5 Late N~
   5 B        AMS    lab-5   5000     50    -20 Site C settlement   <NA>    <NA>   
   6 B        AMS    lab-6   6000     60    -25 Site C settlement   Oven 4  Early ~
   7 C        AMS    lab-7   7000     70    -15 Site D Camp         Hut 2   Mesoli~
   8 C        AMS    lab-8   8000     80    -20 Site D Camp         Hut 2   Mesoli~
   9 C        AMS    lab-9   9000     90    -25 Site D Camp         Hut 3   Mesoli~
   # ... with 9 more variables: culture <chr>, material <chr>, species <chr>,
   #   region <chr>, country <chr>, lat <dbl>, lon <dbl>, shortref <chr>,
   #   comment <chr>
   > plot(example_c14_date_list)
   Error: R packages globe needed for this function to work. Please install with install.packages(c('globe'))
   Execution halted

in the test_that() subpart

== Failed tests ================================================================
-- Error (test_c14_date_list_basic.R:79:3): a file produced from plot.c14_date_list has approximately the correct size --
Error: R packages globe needed for this function to work. Please install with install.packages(c('globe'))
Backtrace:
    x
 1. +-base::plot(example_c14_date_list) at test_c14_date_list_basic.R:79:2
 2. \-c14bazAAR:::plot.c14_date_list(example_c14_date_list)
 3.   \-c14bazAAR:::check_if_packages_are_available("globe")
-- Error (test_c14_date_list_country_attribution.R:7:1): (code run outside of `test_that()`) --
Error: R packages sf, rworldxtra, rgeos, lwgeom needed for this function to work. Please install with install.packages(c('sf', 'rworldxtra', 'rgeos', 'lwgeom'))
Backtrace:
    x
 1. +-c14bazAAR::determine_country_by_coordinate(example_c14_date_list) at test_c14_date_list_country_attribution.R:7:0
 2. \-c14bazAAR:::determine_country_by_coordinate.c14_date_list(example_c14_date_list)
 3.   \-c14bazAAR:::check_if_packages_are_available(...)

[ FAIL 2 | WARN 1 | SKIP 0 | PASS 68 ]
Error: Test failures
Execution halted
nevrome commented 1 year ago

Thanks for #160, @zoometh! I'll look into it some time next week :+1:

The errors you see here are not an issue of c14bazAAR. If you read the messages again, you'll see that the checks and tests error out because you lack some R packages on your system: rnaturalearth, globe, sf, rworldxtra, rgeos and lwgeom. I have them installed and get 0 errors ✔ | 0 warnings ✔ | 0 notes ✔.

These packages haven't been installed with the package for you, because they are listed in the Suggests: field of the DESCRIPTION file. I think the easiest way to install every dependency may be to run something like devtools::install_dev_deps(dependencies = TRUE).

zoometh commented 1 year ago

Following your leads, I have only one note:

> checking R code for possible problems ... NOTE
  get_neonet: no visible global function definition for 'read.table'
  Undefined global functions or variables:
    read.table
  Consider adding
    importFrom("utils", "read.table")
  to your NAMESPACE file.

It concerns the get_neonet() function, Line 8:

c14dates <- read.table(db_url, quote = "", sep = "\t", header = T)

can be replaced by:

c14dates <- data.table::fread(db_url)

nevrome commented 1 year ago

Good :+1: - I consider this solved then

zoometh commented 1 year ago

Thanks @nevrome

zoometh commented 1 year ago

We have just completed collection of a new dataset, named NeoNet Atl, for Europe's South Atlantic river basins. This dataset complements the (first) NeoNet dataset focused on the river basins of the north-central and western Mediterranean (see here). NeoNet Atl dataset has exactly the same structure as the first NeoNet dataset already collected by get_neonet(). Is it worth creating a new function (get_neonet_atl()) or updating get_neonet() to collect both datasets?