September 25, 2017
dplyr
package (continued)dplyr
demo repositoryPull up demo repository we used during class last time.
If you need to re-clone, find the repo on the website, fall17.cds101.com
Load in RStudio, and follow along in demos
mutate()
mutate()
: common creation functions (commands)Many different operators and functions can be used with mutate()
Arithmetic operators: +
, -
, *
, /
, ^
Modular arithmetic
%/%
: integer division
%%
: remainder
Logs: log()
Logical comparisons: <
, <=
, >
, >=
, !=
mutate()
demoFollow along in RStudio
group_by()
and summarize()
summarize()
n()
: Counts number of rows in a group
sum()
: For numerical variables, sums rows within a group
statistical: mean()
, median()
, sd()
, min()
, max()
Counts and proportions of logical values: sum(x > 10)
, mean(y == 0)
group_by()
and summarize()
demoFollow along in RStudio