Tutorial by Examples

For this, we will use the function aggregate, which can be used as follows: aggregate(formula,function,data) The following code shows various ways of using the aggregate function. CODE: df = data.frame(group=c("Group 1","Group 1","Group 2","Group 2",&quo...
Aggregating with dplyr is easy! You can use the group_by() and the summarize() functions for this. Some examples are given below. CODE: # Aggregating with dplyr library(dplyr) df = data.frame(group=c("Group 1","Group 1","Group 2","Group 2","Group 2&...
Grouping with the data.table package is done using the syntax dt[i, j, by] Which can be read out loud as: "Take dt, subset rows using i, then calculate j, grouped by by." Within the dt statement, multiple calculations or groups should be put in a list. Since an alias for list() is .(), bo...

Page 1 of 1