✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Specifying the bin size for a histogram with date data

I am trying to make a histogram that counts up occurrences through time, binned by year, but I am having trouble specifying the bin size. I attempted to feed this in as the size argument to the xbins parameter:

'# size as a difftime magnitude
xbins = list(size = as.difftime(365,units = “days”))

'# also tried size as “M12”, the string value that represents one year
'# (as used for the layout > xaxis > dtick parameter)
xbins = list(size = "M12)

Neither of these worked. Any ideas for how to overcome this problem?

Thanks!