use_template: Use biometryassist analysis templates

View source: R/use_template.R

use_templateR Documentation

Use biometryassist analysis templates

Description

use_template() copies a pre-built analysis template from the biometryassist package to your working directory and optionally opens it for editing. These templates provide standardized approaches for common biometric analyses.

Usage

use_template(
  template_name = "mixed_model_template.R",
  dest_dir = ".",
  open = TRUE,
  overwrite = FALSE,
  output_name = NULL
)

Arguments

template_name

character(1) Name of the template file to use. Default is "mixed_model_template.R". Available templates can be listed with list_templates().

dest_dir

character(1) Directory where the template should be copied. Default is the current working directory (".").

open

logical(1) Should the template file be opened in the default editor after copying? Default is TRUE.

overwrite

logical(1) Should existing files be overwritten? Default is FALSE to prevent accidental data loss.

output_name

character, Optional. Name for the copied file in the destination directory. If not specified, defaults to "analysis_script.R". If specified, the template will be copied and renamed to this file. (The original template file is not overwritten.)

Details

This function is designed to help users get started with biometryassist analyses by providing tested, documented templates. The templates include:

  • Commented code explaining each step

  • Suggested package loading

  • Example data structures

  • Common analysis workflows

If a file with the same name already exists in the destination directory, the function will not overwrite it unless overwrite = TRUE is specified. In this case, it will still open the existing file if open = TRUE.

Value

The file path to the copied template (invisibly). Called primarily for its side effects of copying and optionally opening the template file.

See Also

  • list_templates() to see available templates

  • vignette("analysis-workflow", package = "biometryassist") for analysis guidance

Examples

## Not run: 
# Copy and open the default analysis template
use_template()

# Copy a specific template without opening
use_template("anova_template.R", open = FALSE)

# Copy to a specific directory
use_template("mixed_model_template.R", dest_dir = "analyses")

# Overwrite an existing file
use_template("mixed_model_template.R", overwrite = TRUE)

## End(Not run)


biometryassist documentation built on June 11, 2025, 5:08 p.m.