Skip to content

Instantly share code, notes, and snippets.

@seankross
Created October 5, 2017 19:15
Show Gist options
  • Save seankross/fe932d6fa6d916617b75bbc430b80dc5 to your computer and use it in GitHub Desktop.
Save seankross/fe932d6fa6d916617b75bbc430b80dc5 to your computer and use it in GitHub Desktop.
library(dplyr)
c(2, 5, 6) %>% sum()
cars_i_want <- mtcars %>%
filter(mpg > 20) %>%
filter(cyl == 4) %>%
arrange(hp)
mtcars %>%
group_by(cyl) %>%
summarize(avg_mpg = mean(mpg))
library(tibble)
subjects <- tribble(
~Name, ~Sex, ~Age,
"Emily", "F", 22,
"Stephan", "M", 25,
"Sean", "M", 26
)
data <- data_frame(Name = sample(c(subjects$Name, "Bob"), 20, replace = TRUE),
Measurement = sample(1:10, 20, replace = TRUE))
data %>%
left_join(subjects)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment