Read data into R

data <- read.csv("DataSalinity_SFbar_FortPoint.csv")

head(data)
##                  Date WaterTemp Salinity  Location
## 1 2021-10-10 08:00:00     17.36    31.87 FortPoint
## 2 2021-10-10 08:06:00     17.37    31.87 FortPoint
## 3 2021-10-10 08:12:00     17.36    31.86 FortPoint
## 4 2021-10-10 08:18:00     17.34    31.86 FortPoint
## 5 2021-10-10 08:24:00     17.34    31.86 FortPoint
## 6 2021-10-10 08:30:00     17.34    31.86 FortPoint
tail(data)
##                      Date WaterTemp Salinity Location
## 14962 2021-11-11 07:35:00     14.57       NA  SanFran
## 14963 2021-11-11 07:40:00     14.61       NA  SanFran
## 14964 2021-11-11 07:45:00     14.61       NA  SanFran
## 14965 2021-11-11 07:50:00     14.61       NA  SanFran
## 14966 2021-11-11 07:55:00     14.65       NA  SanFran
## 14967 2021-11-11 08:00:00     14.65       NA  SanFran
summary(data)
##      Date             WaterTemp        Salinity       Location        
##  Length:14967       Min.   :11.61   Min.   :27.65   Length:14967      
##  Class :character   1st Qu.:14.15   1st Qu.:30.56   Class :character  
##  Mode  :character   Median :14.82   Median :31.94   Mode  :character  
##                     Mean   :14.67   Mean   :31.34                     
##                     3rd Qu.:15.20   3rd Qu.:32.12                     
##                     Max.   :17.37   Max.   :32.41                     
##                                     NA's   :9175

Making sure dates are actually read as dates: dates with times

library(chron)

data$Date <- as.chron(data$Date)
summary(data)
##       Date                       WaterTemp        Salinity    
##  Min.   :(10/10/21 01:00:00)   Min.   :11.61   Min.   :27.65  
##  1st Qu.:(10/17/21 06:05:00)   1st Qu.:14.15   1st Qu.:30.56  
##  Median :(10/24/21 07:15:00)   Median :14.82   Median :31.94  
##  Mean   :(10/25/21 11:28:33)   Mean   :14.67   Mean   :31.34  
##  3rd Qu.:(11/02/21 09:37:30)   3rd Qu.:15.20   3rd Qu.:32.12  
##  Max.   :(11/11/21 12:55:00)   Max.   :17.37   Max.   :32.41  
##                                                NA's   :9175   
##    Location        
##  Length:14967      
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 

Plotting graphs

plot(data$Date, data$Salinity, col = "green")

## Adding a line at Oct 24th 2021

plot(data$Date, data$Salinity, col = "green")
abline(v = as.chron("10/24/21"))

library(ggplot2)
ggplot(data, aes(Date, Salinity))+
  geom_point(aes(alpha = 0.5, col = "steelblue")) + scale_x_chron() +
  geom_vline(xintercept = as.chron("10/24/21"), linetype = 2, linewidth = 1, colour = "blue") + 
  facet_grid(~Location)
## Warning: Removed 9175 rows containing missing values (`geom_point()`).

ggplot(data, aes(Date, WaterTemp)) +
  geom_point(aes(alpha = 0.5, col = Location)) + scale_x_chron() +
  geom_vline(xintercept = as.chron("10/24/21"), linetype = 2, linewidth = 1, colour = "blue")