Skip to content

Instantly share code, notes, and snippets.

@terashim
Created April 25, 2019 03:35
Show Gist options
  • Save terashim/3e1b0285a6d3272cb37551089eb7de28 to your computer and use it in GitHub Desktop.
Save terashim/3e1b0285a6d3272cb37551089eb7de28 to your computer and use it in GitHub Desktop.
summarise_allで適用する関数にオプション引数を与える実験
# 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