rowdiff {manymodelr} | R Documentation |
Get row differences between values
Description
This function returns the differences between rows depending on the user's choice.
Usage
rowdiff(
df,
direction = "forward",
exclude = NULL,
na.rm = FALSE,
na_action = NULL,
...
)
Arguments
df |
The data set for which differences are required |
direction |
One of forward and reverse. The default is forward meaning the differences are calculated in such a way that the difference between the current value and the next is returned |
exclude |
A character vector specifying what classes should be removed. See examples below |
na.rm |
Logical. Should missing values be removed? The missing values referred to are those introduced during the calculation ie when subtracting a row with itself. Defaults to FALSE. |
na_action |
If na.rm is TRUE, how should missing values be replaced? Depending on the value as set out in ‘na_replace', the value can be replaced as per the user’s requirement. |
... |
Other arguments to 'na_replace'. |
Value
A data.frame object of row differences
See Also
Examples
# Remove factor columns
data("yields", package="manymodelr")
rowdiff(yields,exclude = "factor",direction = "reverse")
rowdiff(yields[1:5,], exclude="factor", na.rm = TRUE,
na_action = "get_mode",direction = "reverse")