Created
May 12, 2016 17:42
-
-
Save Plaudenslager/d2bd5a2c326b0e53312525d4ab67d45a to your computer and use it in GitHub Desktop.
Group data into date-oriented buckets, e.g. week or month in R
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(dplyr) | |
# Signup.Date is original date information in Date format | |
# Signup.Week is beginning date of week that contains Signup.Date | |
# cut function can take other parameters instead of "weeks": "day", "week", "month", "quarter" and "year" | |
# adds a column of dates to the dataframe that groups data into week-long buckets | |
clean_data <- clean_data %>% mutate(Signup.Week = cut(Signup.Date, "weeks")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment