# one grouping variable
by2(mtcars, .vrb.nm = c("mpg","cyl","disp"), .grp.nm = "vs",
.fun = cov, use = "complete.obs")
# two grouping variables
x <- by2(mtcars, .vrb.nm = c("mpg","cyl","disp"), .grp.nm = c("vs","am"),
.fun = cov, use = "complete.obs")
print(x)
str(x)
# compare to by
vrb_nm <- c("mpg","cyl","disp") # Roxygen runs the whole script if I put a c() in a []
grp_nm <- c("vs","am") # Roxygen runs the whole script if I put a c() in a []
y <- by(mtcars[vrb_nm], INDICES = mtcars[grp_nm],
FUN = cov, use = "complete.obs", simplify = FALSE)
str(y) # has dimnames rather than names
Run the code above in your browser using DataLab