
Last chance! 50% off unlimited learning
Sale ends in
This function returns the differences between rows depending on the user's choice.
rowdiff(
df,
direction = "forward",
exclude = NULL,
na.rm = FALSE,
na_action = NULL,
...
)
A data.frame object of row differences
The data set for which differences are required
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
A character vector specifying what classes should be removed. See examples below
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.
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`.
na_replace
# 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")
Run the code above in your browser using DataLab