I am trying to make a scatterplot with salinity on the y-axis and Date/Time on x-axis. However, when I try to plot it my x-axis data is getting cut off before the end of my data. I've tried adding an xlim but I get an error. See below
p_OY1 <- ggplot(data = OY1, aes(x=date_time2, y=Salinity)) + geom_point() + ylim=c(0,12) + xlim=c("0019-10-04 00:00:00", "0020-06-10 00:00:00")+ theme_classic()+
scale_x_discrete("Date", breaks=c("0019-10-04 10:30:00", "0019-11-01 00:00:00", "0019-12-01 00:00:00", "0020-01-01 00:00:00", "0020-02-01 00:00:00",
"0020-03-01 00:00:00","0020-04-01 00:00:00", "0020-05-01 00:00:00", "0020-06-01 00:00:00"),
labels=c("10/4/2019", "11/1/2019", "12/1/2019", "1/1/2020", "2/1/2020", "3/1/2020", "4/1/2020", "5/1/2020", "6/1/2020"))+ylab("Salinity")+ggtitle("OY1")
Error:
Error in c("0019-10-04 00:00:00", "0020-06-10 00:00:00") + scale_x_discrete("Date", : non-numeric argument to binary operator
OY1 Data
> dput(head(OY1))
structure(list(Site = c("OY1", "OY1", "OY1", "OY1", "OY1", "OY1"
), Date = c("10/4/19", "10/4/19", "10/4/19", "10/4/19", "10/4/19",
"10/4/19"), Time = structure(c(37800, 39600, 41400, 43200, 45000,
46800), class = c("hms", "difftime"), units = "secs"), Salinity = c(0.891307674,
0.960962348, 1.015788098, 1.096679068, 1.191564305, 1.272517514
), Date_time = c("10/4/19 10:30:00", "10/4/19 11:00:00", "10/4/19 11:30:00",
"10/4/19 12:00:00", "10/4/19 12:30:00", "10/4/19 13:00:00")), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"), problems = structure(list(
row = 4550L, col = "Salinity", expected = "a double", actual = "#VALUE!",
file = "'~/Documents/TAMUG_Thesis/Rollover_Pass_Data/Logger/RP_LoggerData_OY1.csv'"), row.names = c(NA,
-1L), class = c("tbl_df", "tbl", "data.frame")))
Can anyone help? I've been messing with this for far too long. Thanks!