The package is built around the idea that a data point consists of a
(variable, key, value) triple identifying an attribute, target, and value.
This notion of data differs from Wickham's notion of "tidy" data, which allows
only (variable, value) pairs. Having explicit support for keys makes it
easier to link different measurements made on the same set of individuals and
makes it easier to identify the sources giving rise to downstream results. R
data.frame
objects have partial support for keys through their rownames
;
the dataset
object extends this support by allowing non-character and
multi-component keys.
Split the rows according to groups defined by one or more columns, optionally performing a computation on each group.
# split the rows into groups defined by unique ('cyl', 'gear') combinations; # the grouping factors are the keys for the result xg <- group(mtcars, cyl, gear) # perform a computation on all groups do(xg, function(x) record(n = nrow(x), mpg = mean(x$mpg), hp = mean(x$hp))) #> cyl gear │ n mpg hp #> 6 4 │ 4 19.750 116.5000 #> 4 4 │ 8 26.925 76.0000 #> 6 3 │ 2 19.750 107.5000 #> 8 3 │ 12 15.050 194.1667 #> 4 3 │ 1 21.500 97.0000 #> 4 5 │ 2 28.200 102.0000 #> 8 5 │ 2 15.400 299.5000 #> 6 5 │ 1 19.700 175.0000
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.