切 week / month :
log$Month <- as.Date(cut(log$Date, breaks = "month"))
log$Week <- as.Date(cut(log$Date, breaks = "week", start.on.monday = FALSE))
统计并画图:
ggplot(data = log,
aes(Month, Quantity)) +
stat_summary(fun.y = sum, # adds up all observations for the month
geom = "bar") + # or "line"
scale_x_date(
labels = date_format("%Y-%m"),
没有评论:
发表评论