rock_import_and_export.Rd
The Reproducible Open Coding Kit (ROCK) format is a format for
open and transparent storage and analysis of qualitative data. In
systematic reviews, you often want to extract an entity as raw text,
so that you can apply a structured coding procedure to the raw text
fragments without exposing the coders to other extracted information (to
minimize bias) while basing the coding on the full overview of all extracted
information (to facilitate identification of sensible codes/categories).
By exporting these entities to the ROCK format
with rxs_export_to_rock()
, the
regular workflows used for qualitative research can be used, after which
the coded sources can be imported back into metabefor
and merged with
the Rxs project using rxs_import_from_rock()
.
rxs_export_to_rock(
x,
entityId = NULL,
outputFile = NULL,
rxsEntityId = metabefor::opts$get("rockInterfacing_rxsEntityId"),
rxsSourceId = metabefor::opts$get("rockInterfacing_rxsSourceId")
)
rxs_import_from_rock(
x,
input = NULL,
newEntityIds = "%s_%s",
newEntityIdCodeFirst = FALSE,
filenameRegex = NULL,
recursive = TRUE,
silent = metabefor::opts$get("silent"),
rxsSourceId = metabefor::opts$get("rockInterfacing_rxsSourceId"),
rxsEntityId = metabefor::opts$get("rockInterfacing_rxsEntityId")
)
The Rxs object, either an Rxs project (as produced
by rxs_parseExtractionScripts()
) or a single Rxs
extraction tree, to export from or merge into.
The identifier of the entity to create a source for.
Optionally, a file to write the source to. If no file is specified, the resulting character vector will be returned visibly (if an output file is specified, it will be returned invisibly).
The class instance identifiers to use in the ROCK source to identify instances of the 'entity' and 'source' classes. Note that source here refers to a source in the systematic review, i.e. an Rxs tree; not to be confused with a ROCK source (i.e. a plain text file with one or more data fragments to code).
The filename or path with files from which to import the ROCK sources, or a character vector with the source's text.
To determine how the new entity
identifiers are composed, newEntityIds
s used. This has to be a
base::sprintf fmt
string containing exactly two occurrences of "%s
".
If newEntityIdCodeFirst
is FALSE
, the first %s
is replaced by the
the original entity identifier (stored using the rxsEntityId
class
instance identifier in the ROCK format), and the second by the code. If it is
TRUE
, this order is reversed.
Optionally, a regular expression: if not NULL
, only
files matching this regualr expression will be imported.
Whether to read directories recursively
Whether to be chatty or silent.
The ROCK source as a character vector, invisibly, unless
an outputFile
is specified for metabefor::rxs_export_to_rock()
. However,
note that metabefor::rxs_import_from_rock()
also modifies the Rxs object
in place (based on the "pass by reference" logic used by data.tree
).
### Load an example Rxs project
data('example_rxsProject_1', package="metabefor");
### Export the titles to a ROCK source
ROCK_source <-
metabefor::rxs_export_to_rock(
example_rxsProject_1,
entityId = "sourceTitle"
);
#> Error in metabefor::rxs_export_to_rock(example_rxsProject_1, entityId = "sourceTitle"):
#> -------- ! metabefor error, please read carefully ! --------
#>
#> To export to ROCK format, you need the `rock` R package. To
#> install it, can use:
#>
#> install.packages('rock');
#>
#> ---------------- ! Thank you for reading ! -----------------
#>
### Show the result
cat(ROCK_source, sep="\n");
#> Error in eval(expr, envir, enclos): object 'ROCK_source' not found
### Apply ROCK codes
ROCK_source[5] <-
paste(
ROCK_source[5],
"[[pan]]"
);
#> Error in eval(expr, envir, enclos): object 'ROCK_source' not found
ROCK_source[11] <-
paste(
ROCK_source[11],
"[[boot]]"
);
#> Error in eval(expr, envir, enclos): object 'ROCK_source' not found
### Show coded result
cat(ROCK_source, sep="\n");
#> Error in eval(expr, envir, enclos): object 'ROCK_source' not found
### Import the result again
metabefor::rxs_import_from_rock(
example_rxsProject_1,
ROCK_source
);
#> Error in metabefor::rxs_import_from_rock(example_rxsProject_1, ROCK_source):
#> -------- ! metabefor error, please read carefully ! --------
#>
#> To export to ROCK format, you need the `rock` R package. To
#> install it, can use:
#>
#> install.packages('rock');
#>
#> -------- ! -------------------------------------- ! --------
#>
### Check both sources to see that the codes were imported
example_rxsProject_1$rxsTrees$qurid_7h50rzpq$general;
#> levelName
#> 1 general
#> 2 ¦--publicationYear
#> 3 ¦--sourceAuthors
#> 4 ¦--sourceTitle
#> 5 °--modeInfo
example_rxsProject_1$rxsTrees$qurid_7h50rzmz$general;
#> levelName
#> 1 general
#> 2 ¦--publicationYear
#> 3 ¦--sourceAuthors
#> 4 °--sourceTitle
### Look at the values (1s and 0s indicating whether
### the code was applied for that source)
metabefor::rxsTree_to_valueDf(
example_rxsProject_1$rxsTrees$qurid_7h50rzpq
)[3:5, ];
#> path entity nodeValue
#> 3 source/general sourceTitle Ten lifehacks with a frying pan
#> 4 source/general modeInfo Lots of more info
#> 5 source/methods/sample sampleSize 1