Adds one or more records to a literature matrix at a specified position. Records can be provided as lists or data frames, and can be inserted before or after specific rows.
Arguments
- .data
A data frame to which records will be added
- ...
One or more records to add. Each record can be either:
A list with the same length as the number of columns in `.data`
A data frame with the same column structure as `.data`
- .before
Row number before which to insert the new records. If NULL (default), and `.after` is also NULL, records are appended to the end.
- .after
Row number after which to insert the new records. If NULL (default), and `.before` is also NULL, records are appended to the end.
Examples
# Create sample data frame
df <- data.frame(
name = c("John", "Jane"),
age = c(25, 30)
)
# Add a single record as a list
df <- add_batch_record(df, list(name = "Bob", age = 35))
# Add multiple records as data frames
new_records <- data.frame(
name = c("Alice", "Charlie"),
age = c(28, 40)
)
df <- add_batch_record(df, new_records, .before = 2)