This function extracts specific rows from a data frame along with their context, based on a given range.
It can take either a vector of row numbers or a boolean vector as input. Additionally, the function allows
specifying the direction of the context (above, below, or both) and marks each row as either targeted or context.
Usage
controws(data, input, context = 1, direction = "both")
Value
A dataframe containing the targeted rows and their contextual rows. An additional column
'.RowType' indicates whether it is a row given as input ("->") or part of the context ("").
Arguments
data
A data frame from which rows and their context will be extracted.
input
A numeric vector of row numbers or a logical vector. If a logical vector is given, the function
will extract rows where the vector is TRUE.
context
An integer specifying the number of rows above and/or below the target row to include as context.
Default is 1.
direction
A character string specifying the direction of context to include. Valid options are "up" for
rows above, "down" for rows below, and "both" for both directions. Default is "both".