FUN(arg = c("V1", "V2"), data = x)
which may be stored in advance:
vars <- c("V1", "V2")
FUN(arg = vars, data = x)
where x contains those variables. You may also supply variable
names as symbols:
FUN(arg = V1, data = x)
Or as a list of symbols (similarly to as in aggregate):
FUN(arg = list(V1, V2), data = x)
Or as a list of expressions:
FUN(arg = list(V1 + 1, factor(V2)), data = x)
A formula without a left-hand-side specified is sometimes allowed as well:
FUN(arg = ~ I(V1 + 1) + factor(V2), data = x)
Using a symbol or a list of symbols/expressions typically causes the function to look for the variable(s) first in the supplied data (if any) and then where the function was called. For everyday users this means you might define e.g.
V3 <- factor(letters)
and do e.g.
FUN(arg = list(V1 + 1, factor(V2), V3), data = x)
provided V1 and V2 exist in x or in the function calling
environment.
vars <- c("V2")
FUN(arg = V3, data = x)
where x has a column named vars. This causes the function to
use x$vars and NOT x$V2.
by argument in data.tables -
see ?data.table. There are many ways to supply the same information
to certain functions in