JGCRI/gcamdata

replace_na broken in tidyr 1.2.0

benmsanderson opened this issue · 1 comments

Building xmls in GCAM data system v5.1 is broken in R v4.1 due to a change in functionality of replace_na for dataframes:

Workaround is downgrading tidyr to version 1.1.4.

GCAM Data System v5.1
Found 354 chunks
Found 3351 chunk data requirements
Found 1911 chunk data products
1118 chunk data input(s) not accounted for
Chunks left: 1472
[1] "module_aglu_LA100.0_LDS_preprocessing"
[1] "- make 3.12"
[1] "module_aglu_LA100.FAO_downscale_ctry"
Error in stop_vctrs():
! Can't convert replace$element to match type of data$element .
Backtrace:

  1. └─gcamdata::driver(write_output = FALSE, write_xml = TRUE)
  2. └─gcamdata::run_chunk(chunk, all_data[input_names]) at gcamdata/R/driver.R:295:6
  3. ├─base::do.call(chunk, list(driver.MAKE, all_data)) at gcamdata/R/driver.R:16:2
    
  4. └─gcamdata::module_aglu_LA100.FAO_downscale_ctry("MAKE", `<named list>`)
    
  5.   ├─tidyr::replace_na(FAO_data_ALL, repl) at gcamdata/R/zchunk_LA100.FAO_downscale_ctry.R:274:4
    
  6.   └─tidyr:::replace_na.data.frame(FAO_data_ALL, repl)
    
  7.     └─vctrs::vec_assign(...)
    
  8.       └─vctrs `<fn>`()
    
  9.         └─vctrs::vec_default_cast(...)
    
  10.           └─vctrs::stop_incompatible_cast(...)
    
  11.             └─vctrs::stop_incompatible_type(...)
    
  12.               └─vctrs:::stop_incompatible(...)
    
  13.                 └─vctrs:::stop_vctrs(...)
    
  14.                   └─rlang::abort(message, class = c(class, "vctrs_error"), ...)
    

Execution halted
make: *** [Makefile:5: xml] Error 1

Hi @benmsanderson thanks for sharing! This is a known problem that we are hoping to fix by implementing renv for dependency management (#1174)