I am trying to create a scatterplot with date/time on the x-axis and salinity on the y-axis. However, there are some date/time points which do not have a salinity value due to equipment failure, but I still need these portions of time to show on my graph to help explain the ecological patterns I am looking at. Can anyone advise on how to keep these missing sections shown on the graph?
My current code for the data and the plot which does not show the missing values.
Edit My data has explicit missing values where data was removed due to logger errors but is listed as an 'NA' (see photo). Unfortunately I have thousands of data points collected half hourly so it is difficult to show all of the data.
Screenshot of data showing 'NA' values
OY1_AllTimes <- read_csv("~/Documents/TAMUG_Thesis/Rollover_Pass_Data/Logger/RP_LoggerData_OY1_AllTimes.csv")
summary(OY1_AllTimes)
OY1_AllTimes$Date_time<-paste(OY1_AllTimes$Date, OY1_AllTimes$Time)
summary(OY1_AllTimes$Date_time)
date_time_OY1_AllTimes<-as.POSIXct(OY1_AllTimes$Date_time, format="%m/%d/%Y %H:%M")
date_time_OY1_AllTimes
date_time2_OY1_AllTimes<-as.factor(date_time_OY1_AllTimes)
date_time2_OY1_AllTimes
summary(OY1_AllTimes)
p_OY1_AllTimes <- ggplot(data = OY1_AllTimes, aes(x=date_time2_OY1_AllTimes, y=Salinity)) + geom_point() + theme_classic()+
scale_x_discrete("Date", breaks=c("0019-10-04 09:30:00", "0019-11-01 05: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/2019", "11/2019", "12/2019", "1/2020", "2/2020", "3/2020", "4/2020", "5/2020", "6/2020"))+ylab("Salinity")+ggtitle("OY1")
p_OY1_AllTimes
Scatterplot of OY1 without missing values
Essentially I would like to see the above scatterplot with gaps representing the periods without salinity data so that the date/time scale is continuous.
Subsample of data:
# A tibble: 50 x 5
Site Date Time Salinity Date_time
<chr> <chr> <time> <dbl> <chr>
1 OY1 10/4/19 09:30 NA 10/4/19 09:30:00
2 OY1 10/4/19 10:00 NA 10/4/19 10:00:00
3 OY1 10/4/19 10:30 0.891 10/4/19 10:30:00
4 OY1 10/4/19 11:00 0.961 10/4/19 11:00:00
5 OY1 10/4/19 11:30 1.02 10/4/19 11:30:00
6 OY1 10/4/19 12:00 1.10 10/4/19 12:00:00
7 OY1 10/4/19 12:30 1.19 10/4/19 12:30:00
8 OY1 10/4/19 13:00 1.27 10/4/19 13:00:00
9 OY1 10/4/19 13:30 1.33 10/4/19 13:30:00
10 OY1 10/4/19 14:00 1.42 10/4/19 14:00:00
# … with 40 more rows```