write.design: Write Design Files

View source: R/methods.R

write.designR Documentation

Write Design Files

Description

This function writes a design into a set of files. For each random factor, a unit list is created that contains a list of all levels (instances) of the random factor and the factor levels to which that level is assigned. Moreover, code_files are created that contain a complete set of experimental codes.

Usage

write.design(
  design,
  group_by = NULL,
  order_by = NULL,
  randomize = FALSE,
  run_files = paste0("run", ifelse(length(group_by) > 0L, paste0("_", group_by, "-%",
    seq_along(group_by), "$s", collapse = ""), "")),
  code_files = "codes_%s",
  output_dir,
  output_handler,
  file_extension = NULL,
  ...
)

write.design.csv(..., quote = FALSE, row.names = FALSE)

write.design.xlsx(..., format_headers = FALSE)

write.design.json(..., dataframe = "columns")

Arguments

design

The factorDesign to be written into files.

group_by

Experimental codes are to be grouped by these factors. If NULL, all codes are written into one file. Also see output.design for grouping design output.

order_by

The experimental codes are to be ordered by these columns. Also see output.design for ordering design output.

randomize

After ordering, lines in the same order rank are to be shuffled randomly if set to TRUE.

run_files

The pattern to be used for the file names of the run_files (i.e., files containing the experimental codes). By default, file names are "run_Group1_Othergroup4.ext" ect.

code_files

Code files (files containing conditions for levels of random factors) are named after this pattern.

output_dir

All files are written into this directory.

output_handler

This is the function that is called to write the data frames. If using write.design.csv, this is utils::write.csv and if using write.design.json, this is jsonlite::write_json.

file_extension

This is the file_extension to be added after each file name. Use ” if no file_extension is to be added. If 'NULL', the file_extension is guessed from the output_handler used.

...

Other parameters to be passed on to write.design and the underlying output_handler.

quote, row.names

see utils::write.csv()

format_headers

see writexl::write_xlsx(), default is FALSE

dataframe

see jsonlite::write_json()

Functions

  • write.design.csv(): Using default settings for writing CSV files

  • write.design.xlsx(): Using default settings for writing XLSX files (using the writexl package)

  • write.design.json(): Using default settings for writing JSON files (using the jsonlite package)

See Also

output.design for use of order_by and group_by.

Examples


des <- fixed.factor("Factor1", c("1A","1B")) +
       fixed.factor("Factor2", c("2A","2B")) +
       random.factor("Subject", c("Factor1"))
    
# This writes a CSV file for each subject and a CSV list of subjects
write.design(des, group_by = "Subject", output_handler = write.csv, output_dir = tempdir())

# This writes a single CSV file for all subjects and a CSV list of subjects
write.design(des, output_handler = write.csv, output_dir = tempdir())


designr documentation built on May 31, 2023, 8:40 p.m.