Skip to content

Commit c5ac2eb

Browse files
updated share and author methods
1 parent e5d4666 commit c5ac2eb

8 files changed

Lines changed: 238 additions & 53 deletions

File tree

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
cff-version: 1.2.0
2-
message: "Matthew Hamilton and Caroline Gao (2022). specific: Specify Candidate Models for Representing Mental Health Systems. Version 0.0.0.9074. Zenodo. https://doi.org/10.5281/zenodo.5768689"
2+
message: "Matthew Hamilton and Caroline Gao (2022). specific: Specify Candidate Models for Representing Mental Health Systems. Version 0.0.0.9075. Zenodo. https://doi.org/10.5281/zenodo.5768689"
33
authors:
44
- family-names: "Hamilton"
55
given-names: "Matthew"
66
- family-names: "Gao"
77
given-names: "Caroline"
88
title: "specific: Specify Candidate Models for Representing Mental Health Systems"
9-
version: 0.0.0.9074
9+
version: 0.0.0.9075
1010
doi: 10.5281/zenodo.5768689
11-
date-released: 2022-02-15
11+
date-released: 2022-02-16
1212
url: "https://ready4-dev.github.io/specific/"

DESCRIPTION

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,15 @@ Collate:
119119
'pkg_specific.R'
120120
'specific-package.R'
121121
Suggests:
122-
scorz,
123-
rmarkdown
124-
Remotes:
122+
scorz (>= 0.0.0.9048),
123+
rmarkdown,
124+
betareg,
125+
cmdstanr (>= 0.4.0.9000),
126+
rstan
127+
Remotes:
125128
ready4-dev/ready4,
126129
ready4-dev/ready4show,
127130
ready4-dev/ready4use,
128-
ready4-dev/youthvars
131+
ready4-dev/youthvars,
132+
stan-dev/cmdstanr,
133+
ready4-dev/scorz

R/mthd_author.R

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ methods::setMethod("author", "SpecificModels", function (x, prefd_mdl_types_chr
8484
#' @rdname author-methods
8585
#' @aliases author,SpecificSynopsis-method
8686
#' @export
87-
#' @importFrom purrr map2_chr map_chr
88-
#' @importFrom ready4 write_to_dv_with_wait author
89-
#' @importFrom tibble tibble
87+
#' @importFrom purrr map2_chr
88+
#' @importFrom ready4 author
9089
methods::setMethod("author", "SpecificSynopsis", function (x, reference_1L_int = NA_integer_, type_1L_chr = "Report",
9190
what_1L_chr = "Catalogue")
9291
{
@@ -105,19 +104,6 @@ methods::setMethod("author", "SpecificSynopsis", function (x, reference_1L_int =
105104
.x), fl_nm_1L_chr = fl_nm_1L_chr, what_1L_chr = "Catalogue")
106105
fl_nm_1L_chr
107106
})
108-
if (!is.na(x@e_Ready4useRepos@dv_ds_nm_1L_chr)) {
109-
ready4::write_to_dv_with_wait(dss_tb = tibble::tibble(ds_obj_nm_chr = ctlg_nms_chr,
110-
title_chr = purrr::map_chr(1:length(ctlg_nms_chr),
111-
~paste0("Catalogue of utility mapping models",
112-
ifelse(.x == 1, " (Primary Analysis)", paste0(" (Supplementary Analysis ",
113-
(.x - 1), ")"))))), dv_nm_1L_chr = x@e_Ready4useRepos@dv_nm_1L_chr,
114-
ds_url_1L_chr = x@e_Ready4useRepos@dv_ds_nm_1L_chr,
115-
parent_dv_dir_1L_chr = paste0(x@b_SpecificResults@a_SpecificShareable@shareable_outp_ls$path_to_write_to_1L_chr,
116-
"/H_Dataverse"), paths_to_dirs_chr = paste0(x@a_Ready4showPaths@outp_data_dir_1L_chr,
117-
"/", x@a_Ready4showPaths@reports_dir_1L_chr,
118-
"/", what_1L_chr), inc_fl_types_chr = ".pdf",
119-
paths_are_rltv_1L_lgl = F)
120-
}
121107
}
122108
})
123109
#'
@@ -133,18 +119,21 @@ methods::setMethod("author", "SpecificSynopsis", function (x, reference_1L_int =
133119
#' @rdname author-methods
134120
#' @aliases author,SpecificProject-method
135121
#' @export
122+
#' @importFrom purrr walk
136123
#' @importFrom ready4 author
137124
methods::setMethod("author", "SpecificProject", function (x, fl_nm_1L_chr = "I_ALL_OUTPUT_", path_1L_chr = NA_character_,
138125
type_1L_chr = "results", what_1L_chr = "public")
139126
{
140127
if (type_1L_chr %in% c("purge_all", "purge_write")) {
141-
write_to_delete_mdl_fls(x@c_SpecificResults@a_SpecificShareable@shareable_outp_ls)
128+
outp_smry_ls_ls <- manufactureSlot(x, "c_SpecificResults",
129+
what_1L_chr = "indexed_shareable")
130+
purrr::walk(outp_smry_ls_ls, ~write_to_delete_mdl_fls(.x))
142131
}
143132
if (type_1L_chr != "purge_all") {
144133
path_1L_chr <- ifelse(is.na(path_1L_chr), x@paths_chr[1],
145134
path_1L_chr)
146135
if (type_1L_chr == "results") {
147-
if (what_1L_chr == "public")
136+
if (what_1L_chr %in% c("public", "purge_write"))
148137
output_xx <- x@c_SpecificResults@a_SpecificShareable@shareable_outp_ls
149138
if (what_1L_chr == "private")
150139
output_xx <- x@c_SpecificResults@b_SpecificPrivate@private_outp_ls

R/mthd_share.R

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,96 @@
33
#' @name share-SpecificProject
44
#' @description share method applied to SpecificProject
55
#' @param x An object of class SpecificProject
6-
#' @param fl_nm_1L_chr File name (a character vector of length one)
6+
#' @param fl_nm_1L_chr File name (a character vector of length one), Default: 'mdl_ingredients'
77
#' @param repos_Ready4useRepos PARAM_DESCRIPTION
88
#' @return NULL
99
#' @rdname share-methods
1010
#' @aliases share,SpecificProject-method
1111
#' @export
1212
#' @importFrom ready4 share
13-
methods::setMethod("share", "SpecificProject", function (x, fl_nm_1L_chr, repos_Ready4useRepos)
13+
methods::setMethod("share", "SpecificProject", function (x, fl_nm_1L_chr = "mdl_ingredients", repos_Ready4useRepos)
1414
{
1515
x@c_SpecificResults@b_SpecificPrivate <- SpecificPrivate()
1616
x@paths_chr <- NA_character_
1717
y <- share(repos_Ready4useRepos, obj_to_share_xx = x, fl_nm_1L_chr = fl_nm_1L_chr)
1818
})
19+
#'
20+
#' Share (publish) open data
21+
#' @name share-SpecificSynopsis
22+
#' @description share method applied to SpecificSynopsis
23+
#' @param x An object of class SpecificSynopsis
24+
#' @param consolidate_1L_lgl Consolidate (a logical vector of length one), Default: T
25+
#' @param fl_nm_1L_chr File name (a character vector of length one), Default: 'mdl_ingredients'
26+
#' @param type_1L_chr Type (a character vector of length one), Default: 'Models'
27+
#' @param what_1L_chr What (a character vector of length one), Default: 'ingredients'
28+
#' @return NULL
29+
#' @rdname share-methods
30+
#' @aliases share,SpecificSynopsis-method
31+
#' @export
32+
#' @importFrom purrr reduce map_chr
33+
#' @importFrom dplyr bind_rows distinct mutate
34+
#' @importFrom ready4 write_to_dv_with_wait share
35+
#' @importFrom tibble tibble
36+
methods::setMethod("share", "SpecificSynopsis", function (x, consolidate_1L_lgl = T, fl_nm_1L_chr = "mdl_ingredients",
37+
type_1L_chr = "Models", what_1L_chr = "ingredients")
38+
{
39+
path_to_outp_dir_1L_chr <- x@a_Ready4showPaths@outp_data_dir_1L_chr
40+
if (type_1L_chr == "Models" & what_1L_chr %in% c("ingredients")) {
41+
secondary_1L_int <- x@b_SpecificResults@a_SpecificShareable@shareable_outp_ls %>%
42+
names() %>% startsWith("secondary_") %>% sum()
43+
object_xx <- paste0(path_to_outp_dir_1L_chr, "/Output/G_Shareable/Ingredients/mdl_ingredients.RDS") %>%
44+
readRDS()
45+
if (secondary_1L_int > 0 & consolidate_1L_lgl) {
46+
object_xx <- 1:secondary_1L_int %>% purrr::reduce(.init = object_xx,
47+
~if (.y > 0) {
48+
ingredients_ls <- paste0(path_to_outp_dir_1L_chr,
49+
"/secondary_", .y, "/G_Shareable/Ingredients/mdl_ingredients.RDS") %>%
50+
readRDS()
51+
.x <- append(.x, list(ingredients_ls) %>% setNames(paste0("secondary_",
52+
.y)))
53+
.x$dictionary_tb <- dplyr::bind_rows(.x$dictionary_tb,
54+
ingredients_ls$dictionary_tb) %>% dplyr::distinct()
55+
.x$mdls_lup <- dplyr::bind_rows(.x$mdls_lup,
56+
ingredients_ls$mdls_lup %>% dplyr::mutate(source_chr = paste0("Secondary Analysis ",
57+
LETTERS[.y]))) %>% dplyr::distinct()
58+
.x$mdls_smry_tb <- dplyr::bind_rows(.x$mdls_smry_tb,
59+
ingredients_ls$mdls_smry_tb) %>% dplyr::distinct()
60+
.x$predictors_lup <- dplyr::bind_rows(.x$predictors_lup,
61+
ingredients_ls$predictors_lup) %>% dplyr::distinct()
62+
.x
63+
}
64+
else {
65+
.x$Primary <- .x
66+
.x$mdls_lup <- .x$mdls_lup %>% dplyr::mutate(source_chr = "Primary Analysis")
67+
.x
68+
})
69+
saveRDS(object_xx, paste0(path_to_outp_dir_1L_chr,
70+
"/Output/G_Shareable/Ingredients/mdl_ingredients.RDS"))
71+
}
72+
Y <- share(x@e_Ready4useRepos, obj_to_share_xx = object_xx,
73+
fl_nm_1L_chr = fl_nm_1L_chr)
74+
}
75+
if (type_1L_chr == "Report") {
76+
if (what_1L_chr == "Catalogue") {
77+
ctlg_path_1L_chr <- paste0(path_to_outp_dir_1L_chr,
78+
"/", x@a_Ready4showPaths@reports_dir_1L_chr,
79+
"/", what_1L_chr)
80+
outp_smry_ls_ls <- manufacture(x@b_SpecificResults,
81+
what_1L_chr = "indexed_shareable")
82+
refs_int <- 1:length(outp_smry_ls_ls)
83+
ctlg_nms_chr <- purrr::map_chr(refs_int, ~paste0("AAA_TTU_MDL_CTG",
84+
ifelse(.x == 1, "", paste0("-", (.x - 1)))))
85+
ready4::write_to_dv_with_wait(dss_tb = tibble::tibble(ds_obj_nm_chr = ctlg_nms_chr,
86+
title_chr = purrr::map_chr(1:length(ctlg_nms_chr),
87+
~paste0("Catalogue of utility mapping models",
88+
ifelse(.x == 1, " (Primary Analysis)", paste0(" (Supplementary Analysis ",
89+
(.x - 1), ")"))))), dv_nm_1L_chr = x@e_Ready4useRepos@dv_nm_1L_chr,
90+
ds_url_1L_chr = x@e_Ready4useRepos@dv_ds_nm_1L_chr,
91+
parent_dv_dir_1L_chr = paste0(x@b_SpecificResults@a_SpecificShareable@shareable_outp_ls$path_to_write_to_1L_chr,
92+
"/H_Dataverse"), paths_to_dirs_chr = paste0(x@a_Ready4showPaths@outp_data_dir_1L_chr,
93+
"/", x@a_Ready4showPaths@reports_dir_1L_chr,
94+
"/", what_1L_chr), inc_fl_types_chr = ".pdf",
95+
paths_are_rltv_1L_lgl = F)
96+
}
97+
}
98+
})

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,4 @@ reference:
155155
- renew.specific_models
156156
- renew.specific_predictors
157157
- share-SpecificProject
158+
- share-SpecificSynopsis

data-raw/s4_fns/author.R

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ author_SpecificProject <- function(x,
7373
type_1L_chr = "results",
7474
what_1L_chr = "public"){
7575
if(type_1L_chr %in% c("purge_all","purge_write")){
76-
write_to_delete_mdl_fls(x@c_SpecificResults@a_SpecificShareable@shareable_outp_ls)
76+
outp_smry_ls_ls <- manufactureSlot(x,
77+
"c_SpecificResults",
78+
what_1L_chr = "indexed_shareable")
79+
purrr::walk(outp_smry_ls_ls,
80+
~ write_to_delete_mdl_fls(.x))
7781
}
7882
if(type_1L_chr != "purge_all"){
7983
path_1L_chr <- ifelse(is.na(path_1L_chr),
8084
x@paths_chr[1],
8185
path_1L_chr)
8286
if(type_1L_chr == "results"){
83-
if(what_1L_chr == "public")
87+
if(what_1L_chr %in% c("public", "purge_write"))
8488
output_xx <- x@c_SpecificResults@a_SpecificShareable@shareable_outp_ls
8589
if(what_1L_chr == "private")
8690
output_xx <- x@c_SpecificResults@b_SpecificPrivate@private_outp_ls
@@ -132,26 +136,26 @@ author_SpecificSynopsis <- function(x,
132136
fl_nm_1L_chr
133137
}
134138
)
135-
if(!is.na(x@e_Ready4useRepos@dv_ds_nm_1L_chr)){
136-
ready4::write_to_dv_with_wait(dss_tb = tibble::tibble(ds_obj_nm_chr = ctlg_nms_chr,
137-
title_chr = purrr::map_chr(1:length(ctlg_nms_chr),
138-
~ paste0("Catalogue of utility mapping models",
139-
ifelse(.x==1,
140-
" (Primary Analysis)",
141-
paste0(" (Supplementary Analysis ",
142-
(.x-1),
143-
")"))))),
144-
dv_nm_1L_chr = x@e_Ready4useRepos@dv_nm_1L_chr,
145-
ds_url_1L_chr = x@e_Ready4useRepos@dv_ds_nm_1L_chr,
146-
parent_dv_dir_1L_chr = paste0(x@b_SpecificResults@a_SpecificShareable@shareable_outp_ls$path_to_write_to_1L_chr,"/H_Dataverse"),
147-
paths_to_dirs_chr = paste0(x@a_Ready4showPaths@outp_data_dir_1L_chr,
148-
"/",
149-
x@a_Ready4showPaths@reports_dir_1L_chr,
150-
"/",
151-
what_1L_chr),
152-
inc_fl_types_chr = ".pdf",
153-
paths_are_rltv_1L_lgl = F)
154-
}
139+
# if(!is.na(x@e_Ready4useRepos@dv_ds_nm_1L_chr)){
140+
# ready4::write_to_dv_with_wait(dss_tb = tibble::tibble(ds_obj_nm_chr = ctlg_nms_chr,
141+
# title_chr = purrr::map_chr(1:length(ctlg_nms_chr),
142+
# ~ paste0("Catalogue of utility mapping models",
143+
# ifelse(.x==1,
144+
# " (Primary Analysis)",
145+
# paste0(" (Supplementary Analysis ",
146+
# (.x-1),
147+
# ")"))))),
148+
# dv_nm_1L_chr = x@e_Ready4useRepos@dv_nm_1L_chr,
149+
# ds_url_1L_chr = x@e_Ready4useRepos@dv_ds_nm_1L_chr,
150+
# parent_dv_dir_1L_chr = paste0(x@b_SpecificResults@a_SpecificShareable@shareable_outp_ls$path_to_write_to_1L_chr,"/H_Dataverse"),
151+
# paths_to_dirs_chr = paste0(x@a_Ready4showPaths@outp_data_dir_1L_chr,
152+
# "/",
153+
# x@a_Ready4showPaths@reports_dir_1L_chr,
154+
# "/",
155+
# what_1L_chr),
156+
# inc_fl_types_chr = ".pdf",
157+
# paths_are_rltv_1L_lgl = F)
158+
# }
155159
}
156160

157161
}

0 commit comments

Comments
 (0)