Learn R Programming

surveydown (version 0.5.0)

sd_create_survey: Create a new survey template

Description

This function creates a new survey template by copying files from the package's template directory to a specified path. It handles file conflicts and provides appropriate warnings and feedback.

Usage

sd_create_survey(path = getwd(), structure = "single")

Value

Invisible NULL. The function is called for its side effects of creating files and providing user feedback.

Arguments

path

A character string specifying the directory where the survey template should be created. Defaults to the current working directory.

structure

A character string specifying the template structure to use. Must be either "single" or "multi". Defaults to "single".

Details

The function performs the following steps:

  • If the specified path is the current working directory, it asks for user confirmation.

  • Validates the specified structure ("single" or "multi").

  • Creates the target directory if it doesn't exist.

  • Copies all files from the package's template directory (based on the specified structure) to the target path.

  • Preserves the directory structure of the template.

  • Skips existing files and provides warnings for each skipped file.

  • Handles .Rproj files specially, skipping if any .Rproj file already exists in the target directory.

  • Provides feedback on whether files were copied or if all files already existed.

Examples

Run this code
if (interactive()) {
  # Create a single-page survey template
  sd_create_survey(structure = "single")

  # Create a multi-page survey template
  sd_create_survey(structure = "multi")
}

Run the code above in your browser using DataLab