Last active
March 9, 2017 00:18
-
-
Save plpxsk/70a757315901447703ce7ae4254a8407 to your computer and use it in GitHub Desktop.
Examples of new `dplyr` and `purrr` functionality
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tibble) | |
library(dplyr) | |
## sample data | |
df <- frame_data( | |
~x, ~y, ~z, ~x1, ~x2, ~x3, ~y1, ~y2, ~y99, ~z99, ~zz, | |
99, 2, 3.6, 99, 2, 3.6, 99, 2, 3.6, 99, 2, | |
99, 2, 3.6, 99, 2, 3.6, 99, 2, 3.6, 99, 2, | |
99, 2, 3.6, 99, 2, 3.6, 99, 2, 3.6, 99, 2 | |
) | |
## Example: divide each column by 100 | |
df %>% mutate_all(funs("div_by_100" = . / 100)) %>% glimpse | |
## Example: subtract one column from all others | |
df %>% mutate_all(funs("minus_x" = . - x)) %>% glimpse | |
## More coming soon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference docs: