sync_streams {rock} | R Documentation |
Synchronize multiple streams
Description
This function maps the codes from multiple streams onto a primary stream.
Usage
sync_streams(
x,
primaryStream,
columns = NULL,
anchorsCol = rock::opts$get("anchorsCol"),
sourceId = rock::opts$get("sourceId"),
streamId = rock::opts$get("streamId"),
prependStreamIdToColName = FALSE,
appendStreamIdToColName = FALSE,
sep = " ",
fill = TRUE,
compressFun = NULL,
compressFunPart = NULL,
expandFun = NULL,
colNameGlue = rock::opts$get("colNameGlue"),
silent = rock::opts$get("silent")
)
Arguments
x |
The object with the parsed sources. |
primaryStream |
The identifier of the primary stream. |
columns |
The names of the column(s) to synchronize. |
anchorsCol |
The column containing the anchors. |
sourceId |
The column containing the source identifiers. |
streamId |
The column containing the stream identifiers. |
prependStreamIdToColName , appendStreamIdToColName |
Whether to append or prepend the stream identifier before merging the dataframes together. |
sep |
When not specifying |
fill |
When expanding streams, whether to duplicate elements to fill
the resulting vector. Ignored if |
compressFun |
If specified, when compressing streams, instead of pasting
elements together using separator |
compressFunPart |
A function to apply to the segments that are
automatically created; this can be passed instead of |
expandFun |
If specified, when expanding streams, instead of potentially
filling the new larger vector with elements (if |
colNameGlue |
When appending or prepending stream identifiers, the character(s) to use as "glue" or separator. |
silent |
Whether to be silent ( |
Value
The object with parsd sources, x
, with the synchronization results
added in the $syncResults
subobject.
Examples
### Get a directory with example sources
examplePath <-
file.path(
system.file(package="rock"),
'extdata',
'streams'
);
### Parse the sources
parsedSources <- rock::parse_sources(
examplePath
);
### Add a dataframe, syncing all streams to primary stream !
parsedSources <- rock::sync_streams(
parsedSources,
primaryStream = "streamA",
columns = c("Code1", "Code2", "Code3"),
prependStreamIdToColName = TRUE
);
### Look at two examples
parsedSources$syncResults$mergedSourceDf[
,
c("streamB_Code3", "streamC_Code1")
];