I have a large dataset with dates and times in the POSIXct format. This basically spans two academic years.
#Earliest / last log
#2018-09-02 14:46:56
#2020-10-12 23:30:13
I managed to add an academic Year True / False column to split the two years at the 1st of September 2019:
MViews$AcademicYear1819 <- MViews$earliestlog <= as.Date("2019-09-01 00:00:00")
When I graph this ggplot puts everything chronologically on the x axis, but I would like to overlay the two academic years over each other.
MViews %>%
ggplot(aes(x = earliestlog, fill = "red")) + geom_density(alpha = 0.5)
So basically that September 2018 and September 2019 both start at x = 0.
I tried loads of things, but nothing worked unfortunately. I even tried just adding one year to all the values returning true on being the 1 year earlier academic year, but that works neither somehow.
MViews$EL <- MViews$EL[MViews$AcademicYear1819] %m+% years(1) & MViews$EL[!MViews$AcademicYear1819]
Error in UseMethod("reclass_date", orig) :
no applicable method for 'reclass_date' applied to an object of class "NULL"
In addition: Warning messages:
1: Unknown or uninitialised column: EL
.