I downloaded discharge data for a river from a government website, they had formatted the date and time data as so please see format.
This is my code
library(ggplot2)
ggplot(CHEM_RESULTS, aes(x= `Date and Time`, y=`Discharge (cumec)`, group = 1)) +
geom_line( color="powderblue", size=1, alpha=0.9, linetype=1)
I produced this graph please see graph .
DATA SAMPLE:
head(CHEM_RESULTS)
Date and Time
<chr>
Discharge (cumec)
<dbl>
2024-03-05T00:00:01.000+10:00 3.202
2024-03-05T00:35:01.000+10:00 3.124
2024-03-05T01:00:01.000+10:00 3.040
2024-03-05T01:30:01.000+10:00 2.956
2024-03-05T02:00:01.000+10:00 2.919
2024-03-05T03:00:01.000+10:00 2.867
I think due to the format of the date and time being so long and having so many entries(1896) it is creating the bar on the x axis rather than displaying the data. I do not think all data needs to be shown but some date/time points are needed to provide context. I think it may be challenging to reformat the way the government has given the date/ time data, again given how many entries there are.
I need to overlay other water quality data onto the graph e.g. pH at 4 sites and 4 different time periods. Once I put these points onto the graph will it highlight them? as that would be useful in providing only the necessary date and time information.
any help on how to approach this is greatly appreciated.
Thank you !
tried to make a line graph of river discharge getting a bar on the x axis instead of displaying time stamps
Date and Time
character vector into an R datetime format. For example with:lubridate::ymd_hms(sub("\\.000\\+10\\.00", "", Date and Time))
as.POSIXct()
andstrptime()
strptime(CHEM_RESULTS$
Date and Time,"%Y/%m/%e/%y/%Z", tz = "")
the code ran but I am not sure if I formatted it properly as I still get the square underneath my graph. Thanks!