-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild_2table_example.R
64 lines (49 loc) · 2.1 KB
/
rebuild_2table_example.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
## Simple integration test to rebuild package FD.18005 from the data within
## RigsArkivetRInfoPkg
running_sourced = FALSE
if(sys.nframe()>0) {
## Handle case where this script is source()ed
source_directory <- dirname(sys.frame(1)$ofile)
running_sourced <- TRUE
} else {
## Handle case where we are run from Rscript
file_args = grep("^--file=", commandArgs(trailingOnly=FALSE), value=TRUE)
source_directory <- dirname(gsub("^--file=","",file_args[1]))
}
if (is.null(source_directory) ||
length(source_directory)==0 ||
!file.exists(source_directory)) {
stop("Unable to determine source directory for executing script. Aborting")
}
#library(RigsArkivetRInfoPkg)
library(devtools)
load_all(file.path(source_directory,"RigsArkivetRInfoPkg"))
#pkg_output_dir=file.path(tempdir(), "FD.18005")
pkg_output_dir=file.path("/tmp/testit-multitable", "FD.18005")
pkg_info = list(
archive_index=system.file("extdata", "FD_18005_archiveIndex.xml", package="RigsArkivetRInfoPkg"),
context_doc_index=system.file("extdata", "FD_18005_contextDocumentationIndex.xml", package="RigsArkivetRInfoPkg"),
pkg_id="FD.18005",
tables=list(
list(
name="R_testfil",
label_file=fd_18005_r_labels,
key_variable=c("child_id"),
description="Danish Longitudinal Research Study of Grandparents, Parents and Children - this is data 1",
table_dataset=fd_18005_r,
reference=list(
list(
other_dataset="childrens_pets",
other_variable="child_id",
our_variable="child_id")
)
),
list(
name="childrens_pets",
label_file=example_table2_labels,
key_variable=c("pet_id"),
description="Childrens' pets, to provide a simple example of a 2nd table",
table_dataset=example_table2)))
process_full_info_pkg(pkg_info,
output_dir = pkg_output_dir)
message(sprintf("SUCCESS! Output test package to %s", pkg_output_dir))