code_source | R Documentation |
These functions add codes to one or more
sources that were read with one of the
loading_sources
functions.
code_source(
input,
codes,
indices = NULL,
output = NULL,
decisionLabel = NULL,
justification = NULL,
justificationFile = NULL,
preventOverwriting = rock::opts$get("preventOverwriting"),
rlWarn = rock::opts$get(rlWarn),
encoding = rock::opts$get("encoding"),
silent = rock::opts$get("silent")
)
code_sources(
input,
codes,
output = NULL,
indices = NULL,
outputPrefix = "",
outputSuffix = "_coded",
decisionLabel = NULL,
justification = NULL,
justificationFile = NULL,
recursive = TRUE,
filenameRegex = ".*",
preventOverwriting = rock::opts$get("preventOverwriting"),
encoding = rock::opts$get("encoding"),
silent = rock::opts$get("silent")
)
input |
The source, or list of sources, as
produced by one of the |
codes |
A named character vector, where each element is the code to be added to the matching utterance, and the corresponding name is either an utterance identifier (in which case the utterance with that identifier will be coded with that code), a code (in which case all utterances with that code will be coded with the new code as well), a digit (in which case the utterance at that line number in the source will be coded with that code), or a regular expression, in which case all utterances matching that regular expression will be coded with that source. If specifying an utterance ID or code, make sure that the code delimiters are included (normally, two square brackets). |
indices |
If |
output |
If specified, the coded source will be written here. |
decisionLabel |
A description of the (coding) decision that was taken. |
justification |
The justification for this action. |
justificationFile |
If specified, the justification is appended to
this file. If not, it is saved to the |
preventOverwriting |
Whether to prevent overwriting existing files. |
rlWarn |
Whether to let |
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 |
filenameRegex |
Only input files matching this patterns will be read. |
Invisibly, the coded source object.
### 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);
### Show line 71
cat(loadedExample[71]);
### Specify the rules to code all utterances
### containing "Ipsum" with the code 'ipsum' and
### all utterances containing the code
codeSpecs <-
c("(?i)ipsum" = "ipsum",
"BC|AD|\\d\\d\\d\\ds" = "timeRef");
### Apply rules
codedExample <- code_source(loadedExample,
codeSpecs);
### Show line 71
cat(codedExample[71]);
### Also add code "foo" to utterances with code 'ipsum'
moreCodedExample <- code_source(codedExample,
c("[[ipsum]]" = "foo"));
### Show line 71
cat(moreCodedExample[71]);
### Use the 'indices' argument to add the code 'bar' to
### line 71
overCodedExample <- code_source(moreCodedExample,
"bar",
indices=71);
cat(overCodedExample[71]);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.