International-Soil-Radiocarbon-Database / ISRaD

Repository for the development and release of ISRaD data and tools
https://international-soil-radiocarbon-database.github.io/ISRaD/
24 stars 15 forks source link

compile() example doesn't seem to work #220

Closed bpbond closed 4 years ago

bpbond commented 4 years ago

The documentation for compile has an example that errors when run (at lease for me):

> library(ISRaD)
> # Load example dataset Gaudinski_2001
> database <- ISRaD::Gaudinski_2001
> # Save as .xlsx file
> ISRaD.save.xlsx(
+   database = database,
+   template_file = system.file("extdata", "ISRaD_Master_Template.xlsx", package = "ISRaD"),
+   outfile = file.path(tempdir(), "Gaudinski_2001.xlsx"))
Note: zip::zip() is deprecated, please use zip::zipr() instead
> # Compile .xlsx file/s in dataset_directory into ISRaD database object
> ISRaD.compiled <- compile(tempdir(),
+   write_report = TRUE, write_out = TRUE,
+   return_type = "list", checkdoi = FALSE, verbose = TRUE
+ )
Compiling and checking template files...
 Error in txtProgressBar(min = 1, max = length(data_files), style = 3) : 
  must have 'max' > 'min' 
> 

As far as I can see this occurs because there's only one data file in the directory. Should the progress bar start at 0 not 1?

It also seems like it might be useful to have this check at line 99:

  if(!length(data_files)) {
    warning("No data files found!")
    return(NULL)
  }
jb388 commented 4 years ago

@bpbond Thanks for catching this. I added the textProgressBar recently. I'm not sure why it wasn't throwing an error for me. I'll add the check and change the min value to zero.

jb388 commented 4 years ago

Seems like this is fixed now.