Skip to content

Instantly share code, notes, and snippets.

@grosscol
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grosscol/bdee2a93ed55548b17e1 to your computer and use it in GitHub Desktop.
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.
# 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