You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' Simply create qmd-files and yml-files for mesos reports
89
196
#' @param main_directory String, path to where the _metadata.yml, stub QMD-files and their subfolders are created.
197
+
#' @param mesos_var_subfolder String, optional name of a subfolder of the mesos_var folder in where to place all mesos_group folders.
90
198
#' @param files_to_process Character vector of files used as templates for the mesos stubs.
91
199
#' @param mesos_df List of single-column data frames where each variable is a mesos variable, optionally with a variable label indicating its pretty name. The values in each variable are the mesos groups. NA is silently ignored.
92
200
#' @param main_files Character vector of files for which titles should be set as the mesos_group. Optional but recommended.
93
201
#' @param read_syntax_pattern,read_syntax_replacement Optional strings, any regex pattern to search and replace in the qmd-files. If NULL, will ignore it.
94
202
#' @param qmd_regex String. Experimental feature for allowing Rmarkdown, not yet tested.
95
203
#' @param subtitle_separator String or NULL. If a string will add title and subtitle fields to the _metadata.yml-files in the deepest child folders. The title is the mesos_group. The subtitle is a concatenation of the folder name of the main_directory and the mesos_var label.
204
+
#' @param prefix,suffix String for the include section of the stub qmd files.
96
205
#' @export
97
206
setup_mesos<-function(
98
207
main_directory,
208
+
mesos_var_subfolder="",
99
209
files_to_process,
100
210
mesos_df,
101
211
main_files= c("index", "report"),
102
212
read_syntax_pattern="qs::qread\\('",
103
213
read_syntax_replacement="qs::qread('../",
104
214
qmd_regex="\\.qmd",
105
-
subtitle_separator=" - ") {
215
+
subtitle_separator=" - ",
216
+
prefix='{{< include \"../',
217
+
suffix='\" >}}') {
106
218
## Checks
107
219
108
220
if (!inherits(main_directory, "character") || length(main_directory) ==0) cli::cli_abort("{.arg main_directory} must be a string, not {.obj_type_friendly {main_directory}}")
221
+
if (is.null(mesos_var_subfolder) || length(mesos_var_subfolder) !=1|| is.na(mesos_var_subfolder)) mesos_var_subfolder<-""
109
222
if (!is.character(files_to_process) ||
110
223
length(files_to_process) ==0||
111
224
!all(file.exists(files_to_process))) {
@@ -123,14 +236,19 @@ setup_mesos <- function(
123
236
if (!inherits(main_files, "character")) cli::cli_abort("{.arg main_files} must be a character vector, not a {.obj_type_friendly {main_files}}")
124
237
if (!inherits(read_syntax_pattern, "character")) cli::cli_abort("{.arg read_syntax_pattern} must be a string (regex), not a {.obj_type_friendly {read_syntax_pattern}}")
125
238
if (!inherits(read_syntax_replacement, "character")) cli::cli_abort("{.arg read_syntax_replacement} must be a string (regex), not a {.obj_type_friendly {read_syntax_replacement}}")
126
-
if (!inherits(qmd_regex, "character") || length(qmd_regex) ==0) cli::cli_abort("{.arg qmd_regex} must be a string, not a {.obj_type_friendly {qmd_regex}}")
239
+
if (!inherits(qmd_regex, "character") || length(qmd_regex) !=1) cli::cli_abort("{.arg qmd_regex} must be a string, not a {.obj_type_friendly {qmd_regex}}")
240
+
if (!inherits(prefix, "character") || length(prefix) !=1) cli::cli_abort("{.arg prefix} must be a string, not a {.obj_type_friendly {prefix}}")
241
+
if (!inherits(suffix, "character") || length(suffix) !=1) cli::cli_abort("{.arg suffix} must be a string, not a {.obj_type_friendly {suffix}}")
0 commit comments