I do not know why you are using lubridate for this. If you are just looking for something smaller than xts, you can try this
tapply(bikecounts$Northbound, as.Date(bikecounts$Date, format="%m/%d/%Y"), sum)
Basically, you just need to split by date, and then apply the function.
lubridate can be used to create a grouping factor for split problems. So, for example, if you want to get the amount for each month (ignoring the year)
tapply(bikecounts$Northbound, month(mdy_hms(bikecounts$Date)), sum)
But it just uses wrappers for the basic R functions, and in the case of OP, I believe that the basic function of R as.Date is the simplest (as evidenced by the fact that other answers also ignored your request to use lubridate ;-)).
Something that was not related to the Answer to another Question related to OP split.xts . period.apply splits xts into endpoints and applies a function to each group. You can find endpoints that are useful for a given task using the endpoints function. For example, if you have an xts, x object, then endpoints(x, "months") will give you the line numbers, which are the last line of each month. split.xts uses that to split an xts object - split(x, "months") will return a list of xts objects in which each component has been for another month.
Although split.xts() and endpoints() are primarily intended for xts objects, they also work with some other objects, including simple time-based vectors. Even if you don't want to use xts objects, you can still find a use for endpoints() because of its convenience or speed (implemented in C)
> split.xts(as.Date("1970-01-01") + 1:10, "weeks") [[1]] [1] "1970-01-02" "1970-01-03" "1970-01-04" [[2]] [1] "1970-01-05" "1970-01-06" "1970-01-07" "1970-01-08" "1970-01-09" [6] "1970-01-10" "1970-01-11" > endpoints(as.Date("1970-01-01") + 1:10, "weeks") [1] 0 3 10
I think it is best to use lubridate in this task to parse Date strings in POSIXct objects. those. mdy_hms function in this case.
Here's the xts solution using lubridate to parse Date strings.
x <- xts(bikecounts[, -1], mdy_hms(bikecounts$Date)) period.apply(x, endpoints(x, "days"), sum) apply.daily(x, sum)
For this specific task, xts also has an optimized period.sum function (written in Fortran) that is very fast.
period.sum(x, endpoints(x, "days"))