Skip to contents

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.

Usage

build_outlined_strata_project(outline)

Arguments

outline

A data frame with the following columns: project_path, stratum_name, stratum_order, lamina_name, lamina_order, skip_if_fail.

Value

invisible dataframe of the survey of the strata project.

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-02-03 21:45:56.2153] INFO: Backed up /tmp/RtmpKn24Yq/file1e502bbf0ff9/strata/test2/.laminae.toml to /tmp/RtmpKn24Yq/file1e502bbf0ff9/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/RtmpKn24Yq/file1e502bbf0ff9/strata/test1/lamina1…
#> $ skip_if_fail    <lgl> FALSE, FALSE
#> $ created         <date> 2025-02-03, 2025-02-03
main(tmp)
#> [2025-02-03 21:45:56.3873] INFO: Strata started 
#> [2025-02-03 21:45:56.3878] INFO: Stratum: test1 initialized 
#> [2025-02-03 21:45:56.3881] INFO: Lamina: lamina1 initialized 
#> [2025-02-03 21:45:56.3886] INFO: Executing: my_code 
#> [1] "I am a placeholder, do not forget to replace me!"
#> [2025-02-03 21:45:56.3893] INFO: Stratum: test1 finished 
#> [2025-02-03 21:45:56.3897] INFO: Stratum: test2 initialized 
#> [2025-02-03 21:45:56.3901] INFO: Executing: my_code 
#> [1] "I am a placeholder, do not forget to replace me!"
#> [2025-02-03 21:45:56.3908] INFO: Strata finished - duration: 0.0036 seconds 
fs::dir_delete(tmp)