Last active
August 29, 2015 14:18
-
-
Save grosscol/bdee2a93ed55548b17e1 to your computer and use it in GitHub Desktop.
A naive implementation of doing some counting after data logic for a list of dates and a given source data frame.
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
# Generate your list of dates | |
mydays <- seq.Date( as.Date('2015-01-01'), as.Date('2015-03-09'), by="day") | |
# Write function to sum the number of open dates that occur in sourceData at least 31 days prior to given date. | |
numOpenDates <- function( givenDate ){ | |
retValue <- sum( (givenDate - sourceDate$openDate) > 30 ) | |
retValue | |
} | |
# Apply function to each date in your list of dates(mydays) | |
answer <- lapply(X=mydays, FUN=numOpenDates) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment