Last active
November 17, 2016 20:00
-
-
Save ramnov/e0be973e4087a9f1dd92abf7d36a37f6 to your computer and use it in GitHub Desktop.
Create rollup/aggregate variables in the same dataset
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
install.packages("devtools") | |
install.packages("dplyr") | |
library("devtools") | |
library("dplyr") | |
install_github("RevolutionAnalytics/dplyrXdf") | |
airline_demo_xdf_file <- file.path(rxGetOption("sampleDataDir"), "AirlineDemoSmall.xdf") | |
airline <- RxXdfData(airline_demo_xdf_file) | |
smry <- airline %>% group_by(DayOfWeek) %>% | |
summarise(DayOfWeekMeans=mean(CRSDepTime), | |
DayOfWeekStdDev=sd(CRSDepTime), | |
DayOfWeekMin=min(CRSDepTime), | |
DayOfWeekMax=max(CRSDepTime), | |
DayOfWeekN=n()) | |
airline_demo_with_summary <- left_join(airline, smry, by="DayOfWeek") | |
head(airline_demo_with_summary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment