add_pos_label: Label a Row Based on Label Above or Label Below

Description Usage Arguments Details Value

View source: R/reading.R

Description

Alter labels in a data frame based on relative position of other labels in the data frame.

Usage

1
2
3
4
5
6
add_pos_label(
  my_data = NULL,
  this_label = NULL,
  label_checked = NULL,
  check_above = TRUE
)

Arguments

my_data

a data frame, which needs to include a variable called ‘label’". Default NULL.

this_label

a character string that you want to assign to one or more rows in my_data. Default NULL.

label_checked

a character string; this is the value the function looks for in label when deciding whether to change a given label to this_label. Default NULL.

check_above

a boolean. If TRUE, then the function will check whether to assign this_label to the current row by checking value of label_checked matches the label value in the row above. If FALSE, it will check the row below instead. Default TRUE.

Details

Assigns new values to selected rows of the variable label in a data frame. Pass it a character string for this_label and another for label_checked. It will try to assign the former based on the locations of the latter. For each row it checks in label, it will look at the value in label either in the row above or the row below, as instructed. This is an internal function used when reading in my book-reading history. Where dates for start or end of reading are incomplete, the function currently records an NA.

Value

a data frame corresponding to my_data but with some row values in the label variable changed as requested.


AGDunn/nehnar documentation built on Feb. 8, 2022, 7:17 a.m.