
Prepend lines with one or more class instance identifiers to one or more sources
Source:R/prepend_ciids_to_source.R
, R/prepend_ciids_to_sources.R
adding_ciids_to_sources.Rd
These functions add lines with class instance identifiers to the beginning
of one or more sources that were read with one of the
loading_sources
functions.
Usage
prepend_ciids_to_source(
input,
ciids,
output = NULL,
allOnOneLine = FALSE,
designationSymbol = "=",
preventOverwriting = rock::opts$get("preventOverwriting"),
rlWarn = rock::opts$get(rlWarn),
encoding = rock::opts$get("encoding"),
silent = rock::opts$get("silent")
)
prepend_ciids_to_sources(
input,
ciids,
output = NULL,
outputPrefix = "",
outputSuffix = "_coded",
recursive = TRUE,
filenameRegex = ".*",
preventOverwriting = rock::opts$get("preventOverwriting"),
encoding = rock::opts$get("encoding"),
silent = rock::opts$get("silent")
)
Arguments
- input
The source, or list of sources, as produced by one of the
loading_sources
functions.- ciids
A named character vector, where each element's name is the class identifier (e.g. "codeId" or "participantId") and each element is the class instance identifier.
- output
If specified, the coded source will be written here.
- allOnOneLine
Whether to add all class instance identifiers to one line (
TRUE
) or add then on successive lines (FALSE
).- designationSymbol
The symbol to use to designate an instance identifier for a class (can be "
=
" or ":
" as per the ROCK standard).- preventOverwriting
Whether to prevent overwriting existing files.
- rlWarn
Whether to let
readLines()
warn, e.g. if files do not end with a newline character.- encoding
The encoding to use.
- silent
Whether to be chatty or quiet.
- outputPrefix, outputSuffix
A prefix and/or suffix to prepend and/or append to the filenames to distinguish them from the input filenames.
- recursive
Whether to also read files from all subdirectories of the
input
directory- filenameRegex
Only input files matching this patterns will be read.
Examples
### Get path to example source
examplePath <-
system.file("extdata", package="rock");
### Get a path to one example file
exampleFile <-
file.path(examplePath, "example-1.rock");
### Parse single example source
loadedExample <-
rock::load_source(exampleFile);
### Add a coder identifier
loadedExample <-
rock::prepend_ciids_to_source(
loadedExample,
c("codeId" = "iz0dn96")
);
### Show lines 1-5
cat(loadedExample[1:5]);
#> [[codeId=iz0dn96]] --- metadata: -