Skip to content

Commit 9256589

Browse files
authored
Merge pull request #32 from explodecomputer/tidy-inst-copy
Copy dictionary to /data +two copies of dictionary are now made +one to /data for use (default) +second to /inst/data (for development) +second needs to be loaded to check wocs
2 parents b5d639f + 28baae4 commit 9256589

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5+
.Rprofile

R/dictionary.r

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,18 @@ combineDictionaries <- function() {
3737

3838

3939
retrieveDictionary <- function(name) {
40-
if (name %in% ls(envir=globals)) {
41-
get(name, envir=globals)
40+
if (name %in% ls(envir = globals)) {
41+
get(name, envir = globals)
42+
} else {
43+
# Try loading from package /data folder
44+
path <- system.file("data", paste0(name, ".rdata"), package = "alspac")
45+
if (file.exists(path)) {
46+
load(path, envir = globals)
47+
get(name, envir = globals)
4248
} else {
43-
stop("dictionary '", name, "' does not exist")
49+
stop("dictionary '", name, "' does not exist")
4450
}
51+
}
4552
}
4653

4754
saveDictionary <- function(name, dictionary) {
@@ -184,6 +191,10 @@ createDictionary <- function(datadir="Current", name=NULL, quick=FALSE, sourcesF
184191
if (!is.null(name)) {
185192
saveDictionary(name, dictionary)
186193
}
194+
## Also save a copy in /inst/data/ for devtools::load_all()
195+
inst_path <- file.path("inst", "data")
196+
if (!dir.exists(inst_path)) dir.create(inst_path, recursive = TRUE)
197+
save(list = name, file = file.path(inst_path, paste0(name, ".rdata")))
187198

188199
invisible(dictionary)
189200
}

inst/data/current.rdata

-824 KB
Binary file not shown.

0 commit comments

Comments
 (0)