to.nda | R Documentation |
This function creates a CSV template file for National Data Archive (NDA) submissions. It extracts the data from a specified data frame and formats it according to NDA requirements, with the structure name split into base name and suffix in the first line. The function will prompt for confirmation before creating the file, with an option to remember the user's preference for future calls.
to.nda(df, path = ".", skip_prompt = FALSE)
df |
Data frame to be used as template or character string naming a data frame in the global environment. |
path |
Character string specifying the directory path where the "tmp" folder and template file should be created. Defaults to the current working directory. |
skip_prompt |
Logical. If TRUE, skips the confirmation prompt. If FALSE (default), will prompt for confirmation unless the user has previously chosen to remember their preference. |
The function will:
Create a 'tmp' directory if it doesn't exist
Parse the structure name into base and suffix components (e.g., "eefrt01" → "eefrt" and "01")
Write the structure name components as the first line
Write column headers as the second line
Write the data rows below
Invisible TRUE if successful. Creates a CSV file at the specified path and prints a message with the file location.
## Not run:
# First create some sample data
eefrt01 <- data.frame(
src_subject_id = c("SUB001", "SUB002"),
interview_age = c(240, 360),
interview_date = c("01/01/2023", "02/15/2023"),
response_time = c(450, 520)
)
# Create the NDA template using the data frame directly
to.nda(eefrt01)
# Or using the name as a string
to.nda("eefrt01")
# Skip the confirmation prompt
to.nda(eefrt01, skip_prompt = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.