I have an in-house R-package with some example data bundled in its inst/extdata
directory.
The problem is that any directory containing "gold" as part of the directory name is quietly ignored by devtools::build()
and by devtools::install()
.
Here is a reproducible example:
# Create packge
library(devtools)
usethis::create_package("~/reprexgold")
Then, within the created R-package project:
# Create some directories
dir.create("inst/extdata/gold", recursive = TRUE)
dir.create("inst/extdata/x_gold", recursive = TRUE)
dir.create("inst/extdata/silver", recursive = TRUE)
dir.create("inst/extdata/x_silver", recursive = TRUE)
# Populate directories
writeLines("hello world", "inst/extdata/gold/test.txt")
writeLines("hello world", "inst/extdata/x_gold/test.txt")
writeLines("hello world", "inst/extdata/silver/test.txt")
writeLines("hello world", "inst/extdata/x_silver/test.txt")
# List directories
dir("inst/extdata", recursive = TRUE)
# > [1] "gold/test.txt" "silver/test.txt" "x_gold/test.txt" "x_silver/test.txt"
# Build package
devtools::install()
# List content of bundled 'extdata' directory
dir(system.file("extdata", package = "reprexgold"), recursive = TRUE)
# > [1] "silver/test.txt" "x_silver/test.txt"
The inst/extdata/*gold
directories are ignored in the build process. No warning is produced.
sessionInfo()
# R version 4.4.1 (2024-06-14)
# Platform: x86_64-pc-linux-gnu
# Running under: Ubuntu 22.04.4 LTS
#
# Matrix products: default
# BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
# LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
#
# locale:
# [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
# [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
# [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#
# time zone: Europe/Berlin
# tzcode source: system (glibc)
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] devtools_2.4.5 usethis_3.0.0
#
# loaded via a namespace (and not attached):
# [1] vctrs_0.6.5 cli_3.6.3 rlang_1.1.4 stringi_1.8.4 purrr_1.0.2 pkgload_1.4.0
# [7] promises_1.3.0 shiny_1.9.1 xtable_1.8-4 glue_1.7.0 htmltools_0.5.8.1 httpuv_1.6.15
# [13] pkgbuild_1.4.4 ellipsis_0.3.2 fastmap_1.2.0 lifecycle_1.0.4 memoise_2.0.1 stringr_1.5.1
# [19] compiler_4.4.1 miniUI_0.1.1.1 sessioninfo_1.2.2 fs_1.6.4 htmlwidgets_1.6.4 Rcpp_1.0.13
# [25] urlchecker_1.0.1 rstudioapi_0.16.0 later_1.3.2 digest_0.6.37 R6_2.5.1 magrittr_2.0.3
# [31] tools_4.4.1 mime_0.12 profvis_0.3.8 remotes_2.5.0 cachem_1.1.0
I do not understand why this is. Thoughts?
I really-really want bundled example data in "gold"-directories... Any suggestions that would allow me to include this feature?
Thanks,
//Carl