rgithubr-devtoolsr-usethis

Installed R github package does not include R/sysdata.Rda


I have an R github package that I can 'successfully' install using devtools::install_github("jwilliman/ethnicNZ") (or remotes::install_github). On github the package contains internal data saved as 'R/sysdata.Rda' using the command usethis::use_data(ethnic05, internal = TRUE).

However, after installation the files 'sysdata.rdb' and 'sysdata.rdx' are missing from the '../Library/ethnicNZ/R' folder, and when running the command ethnicNZ::find_data() from the package I get the error Error in ethnicNZ::find_data() : object 'ethnic05' not found. (These files are present, and the command works if I install the package directly from my local git).

This is possibly a similar issue as accessing sysdata.rda within package functions and R Package Build/Install Error: "object not found" even though I have it in R/sysdata.rda, but neither has an accepted answer. And hopefully my example is reproducible enough for others to troubleshoot.

EDIT

I just noticed on installation I get the error

   Subdirectory 'R' contains invalid file names:
     'sysdata.Rda'

Why is this invalid, and how can I avoid it?

sessionInfo()
#> R version 4.0.0 (2020-04-24)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_New Zealand.1252  LC_CTYPE=English_New Zealand.1252   
#> [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C                        
#> [5] LC_TIME=English_New Zealand.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_4.0.0  magrittr_1.5    tools_4.0.0     htmltools_0.4.0
#>  [5] yaml_2.2.1      Rcpp_1.0.4.6    stringi_1.4.6   rmarkdown_2.1  
#>  [9] highr_0.8       knitr_1.28      stringr_1.4.0   xfun_0.14      
#> [13] digest_0.6.25   rlang_0.4.6     evaluate_0.14

Created on 2020-06-17 by the reprex package (v0.3.0)


Solution

  • Case matters! The file must be called 'sysdata.rda' not 'sysdata.Rda'.

    I discovered that I'd previously saved the data as save(ethnic05, filename = "sysdata.Rda"), then later changed to using usethis::use_data(ethnic05, internal = TRUE). usethis::use_data saved over the previous file but did not correct the case of the extension. I had to delete 'sysdata.Rda', commit and push to github before reinstate the correct sysdata.rda.

    As listed under section 1.1.5 of https://cran.r-project.org/doc/manuals/r-release/R-exts.html,

    "The R subdirectory contains R code files, only. The code files to be installed must ... have one of the extensions13 .R, .S, .q, .r, or .s. ... Two exceptions are allowed: if the R subdirectory contains a file sysdata.rda.