Build a strata project from an outline dataframe
Source:R/build-quick.R
build_outlined_strata_project.Rd
Users with a specific idea in mind already can map out the intended project
structure in an outline dataframe and use build_outlined_strata_project()
to build the project using the dataframe as a blueprint.
Outline
The outline dataframe should have the following columns:
project_path
: The path to the project.stratum_name
: The name of the stratum.stratum_order
: The order of the stratum.lamina_name
: The name of the lamina.lamina_order
: The order of the lamina within the stratum.skip_if_fail
: A logical indicating if the lamina should be skipped if it fails.
Each row of the outline dataframe represents a stratum and lamina combination to be created in the project. A Placeholder R script will be created in each lamina directory to help remind the user to replace it with their own code.
There can only be those 6 columns, and there can be no missing values in the
dataframe. The stratum_name
and stratum_order
columns must contain
unique values.
Examples
tmp <- fs::dir_create(fs::file_temp())
outline <- tibble::tibble(
project_path = tmp,
stratum_name = c("test1", "test2"),
stratum_order = c(1, 2),
lamina_name = c("lamina1", "lamina1"),
lamina_order = c(1, 2),
skip_if_fail = FALSE
)
result <- build_outlined_strata_project(outline)
#> [2025-03-05 13:50:28.5388] INFO: Backed up /tmp/RtmpLS5k5l/file1c2c4db3d6c4/strata/test2/.laminae.toml to /tmp/RtmpLS5k5l/file1c2c4db3d6c4/strata/test2/.laminae.bak
dplyr::glimpse(result)
#> Rows: 2
#> Columns: 7
#> $ execution_order <int> 1, 2
#> $ stratum_name <chr> "test1", "test2"
#> $ lamina_name <chr> "lamina1", "lamina1"
#> $ script_name <chr> "my_code", "my_code"
#> $ script_path <fs::path> "/tmp/RtmpLS5k5l/file1c2c4db3d6c4/strata/test1/lamina1…
#> $ skip_if_fail <lgl> FALSE, FALSE
#> $ created <date> 2025-03-05, 2025-03-05
main(tmp)
#> [2025-03-05 13:50:28.6955] INFO: Strata started
#> [2025-03-05 13:50:28.6959] INFO: Stratum: test1 initialized
#> [2025-03-05 13:50:28.6963] INFO: Lamina: lamina1 initialized
#> [2025-03-05 13:50:28.6968] INFO: Executing: my_code
#> [1] "I am a placeholder, do not forget to replace me!"
#> [2025-03-05 13:50:28.6975] INFO: Stratum: test1 finished
#> [2025-03-05 13:50:28.6979] INFO: Stratum: test2 initialized
#> [2025-03-05 13:50:28.6983] INFO: Executing: my_code
#> [1] "I am a placeholder, do not forget to replace me!"
#> [2025-03-05 13:50:28.6989] INFO: Strata finished - duration: 0.0035 seconds
fs::dir_delete(tmp)