check_above | R Documentation |
This function checks whether each element in a vector x
is the same as the element directly above it
(i.e., the previous value in the vector). If so, it replaces that element with a specified replacement value.
check_above(x, replacement = "")
x |
A vector (typically character or factor) to check for repeated consecutive values. |
replacement |
A value (default is |
This is often useful for visual display in tables, where repeated values in consecutive rows can be suppressed for readability.
A character vector where values that are the same as the previous value are replaced with replacement
.
The first element is always retained.
check_above(c("A", "A", "B", "B", "B", "C"))
# Returns: "A" "" "B" "" "" "C"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.