Hello, I am presenting the following alert:
(DT [, ggplot (.SD, mapping = aes (date, psavert))
+ + geom_point ()
+ + scale_x_datetime (breaks = date_breaks ("10 years"))
+ + labs (y = 'personal saving rate'),])
Error in date_breaks ("10 years"): could not find function "date_breaks"
And I can't find the answer.
Could you help me, guide me !!
I try to reproduce the examples of the following link
Manipulating date breaks and date labels
So far I have only accomplished the following:
library(data.table)
library(ggplot2)
DT<-setDF(economics)#Using the economics dataset
DT<-setDT(DT)
str(DT)
print(DT,topn = 3)
#How does the saving rate vary with time?
(DT[,ggplot(.SD,mapping=aes(date, psavert))
+ geom_point()
+ labs(y='personal saving rate'),])
#Yikes! the calculated breaks are awful, we need to intervene.
#We do so using the date_breaks and date_format functions from mizani.
#Set breaks every 10 years
(DT[,ggplot(.SD,mapping=aes(date, psavert))
+ geom_point()
+ scale_x_datetime(breaks=date_breaks("10 years"))
+ labs(y='personal saving rate'),])
Some correction: is it necessary?