The x axis (date) of my graph is looking terrible since I have monthly data as well as it shows a period of 30 years. The thing I try to do now is to change the date scale from a scale based on months to one based on years. Unfortunately, if I try to run the code the error date_trans works with objects of class Date only, is displayed. In my opinion, this is weird because my date column is already in a date format. Or is the issue related to the fact that my date variable does not contain any days?
Thanks for your help!
My problem was that it have not recognized my variable Date as a date variable.
The following code fixed it. sample_df$Date <- zoo::as.Date(zoo::as.yearmon(sample_df$Date))