Skip to content

Commit 04588bb

Browse files
committed
dictionary update
- fixed the dictionary save function - now makes two copies in /inst and /data
1 parent 30c8e6e commit 04588bb

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

R/dictionary.r

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,23 @@ retrieveDictionary <- function(name) {
4545
}
4646

4747
saveDictionary <- function(name, dictionary) {
48-
# Save in the globals environment
48+
# Save in the globals environment
4949
assign(name, dictionary, globals)
5050

5151
# -------------------------------
5252
# 1️⃣ Save CRAN/GitHub-compliant copy (/data/)
5353
# -------------------------------
54-
data_path <- system.file("data", package = "alspac")
54+
data_path <- file.path(getwd(), "data") # always dev source tree
55+
if (!dir.exists(data_path)) dir.create(data_path, recursive = TRUE)
5556

56-
if (nzchar(data_path)) {
57-
# Installed package case
58-
save(list = name,
59-
file = file.path(data_path, paste0(name, ".rda")),
60-
envir = globals)
61-
} else {
62-
# Dev case (write into source tree)
63-
data_path <- file.path(getwd(), "data")
64-
if (!dir.exists(data_path)) dir.create(data_path, recursive = TRUE)
65-
save(list = name,
66-
file = file.path(data_path, paste0(name, ".rda")),
67-
envir = globals)
68-
}
57+
save(list = name,
58+
file = file.path(data_path, paste0(name, ".rdata")),
59+
envir = globals)
6960

7061
# -------------------------------
7162
# 2️⃣ Save dev copy (/inst/data/) for load_all() testing
7263
# -------------------------------
73-
inst_path <- file.path(getwd(), "inst", "data") # relative to project root
64+
inst_path <- file.path(getwd(), "inst", "data")
7465
if (!dir.exists(inst_path)) dir.create(inst_path, recursive = TRUE)
7566

7667
save(list = name,

data/current.rda

-1.05 MB
Binary file not shown.

data/current.rdata

1.52 MB
Binary file not shown.

0 commit comments

Comments
 (0)