Created
April 25, 2019 03:35
-
-
Save terashim/3e1b0285a6d3272cb37551089eb7de28 to your computer and use it in GitHub Desktop.
summarise_allで適用する関数にオプション引数を与える実験
This file contains hidden or 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
# summarise_allで適用する関数にオプション引数を与える実験 | |
library(tidyverse) | |
data <- read_csv(' | |
a,x | |
A,1 | |
A,2 | |
A,3 | |
B, | |
B,5 | |
B,6 | |
') | |
data | |
data %>% | |
group_by(a) %>% | |
summarise_all(mean) | |
data %>% | |
group_by(a) %>% | |
summarise_all(mean, na.rm = TRUE) # この書き方が便利。オプション引数 na.rm = TRUE が mean に渡される。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment