Description Usage Arguments Details See Also Examples
mutar is literally the same function as [.DataFrame and can be
used as interface to dplyr or data.table. Other functions here listed are a
convenience to mimic dplyr's syntax in a R CMD check friendly way.
These functions can also be used with S4 data.frame(s) / data_frame(s) /
data.table(s). They will always try to preserve the input class.
1 2 3 4 5 6 7 |
x |
(DataFrame | data.frame) |
i |
(logical | numeric | integer | OneSidedFormula | TwoSidedFormula | FormulaList) see the examples. |
j |
(logical | character | TwoSidedFormula | FormulaList | function) character beginning with '^' are interpreted as regular expression |
... |
arbitrary number of args
|
by |
(character) variables to group by. by will be used to do transformations within groups. sby will collapse each group to one row. |
sby |
(character) variables to group by. by will be used to do transformations within groups. sby will collapse each group to one row. |
drop |
(ignored) never drops the class. |
expr |
(expression) any R expression that should be evaluated using data tables reference semantics on data transformations. |
The real workhorse of this interface is mutar. All other functions
exist to ease the transition from dplyr.
OneSidedFormula is always used for subsetting rows.
TwoSidedFormula is used instead of name-value expressions. Instead of
writing x = 1 you simply write x ~ 1.
FormulaList can be used to repeat the same operation on different
columns. See more details in FL.
extract, DataFrame, FL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | data("airquality")
airquality %>%
filtar(~Month > 4) %>%
mutar(meanWind ~ mean(Wind), by = "Month") %>%
sumar(meanWind ~ mean(Wind), by = "Month") %>%
extract("meanWind")
airquality %>%
sumar(
.n ~ mean(.n) | c("Wind", "Temp"),
by = "Month"
)
# Enable data.tables reference semantics with:
withReference({
x <- data.table::data.table(x = 1)
mutar(x, y ~ 2)
})
## Not run:
# Use dplyr as back-end:
options(dat.use.dplyr = TRUE)
x <- data.frame(x = 1)
mutar(x, y ~ dplyr::n())
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.