Skip to content

Commit 6d03260

Browse files
committed
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
1 parent d011cf1 commit 6d03260

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.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: 15 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) {
@@ -158,6 +165,11 @@ createDictionary <- function(datadir="Current", name=NULL, quick=FALSE, sourcesF
158165
saveDictionary(name, dictionary)
159166
}
160167

168+
## Also save a copy in /inst/data/ for devtools::load_all()
169+
inst_path <- file.path("inst", "data")
170+
if (!dir.exists(inst_path)) dir.create(inst_path, recursive = TRUE)
171+
save(list = name, file = file.path(inst_path, paste0(name, ".rdata")))
172+
161173
invisible(dictionary)
162174
}
163175

inst/data/current.rdata

729 KB
Binary file not shown.

0 commit comments

Comments
 (0)