I have a dataset of water quality data with Date, Result, Parameter, Station in R. I am trying to extract the first and last date that a sample was taken PER station which would take up two new columns at the end of my dataframe. I also have columns for Month, Day, and Year.
Here is the structure:
'data.frame': 50954 obs. of 8 variables:
$ Date : chr "6/9/2016" "6/9/2016" "6/8/2016" "6/8/2016" ...
$ Result : num 400 160 2200 260 660 550 2100 270 750 82 ...
$ Units : chr "M" "M" "M" "M" ...
"Fecal coliforms" ...
$ Station : chr "RIO GRANDE DE MANATI AT HWY 2 NR MANATI, PR" "RIO GRANDEE DE MANATI AT HWY 2 NR MANATI, PR" "RIO CAONILLAS NR JAYUYA, PR"
"RIO CAONILLAS NR JAYUYA, PR" ...
$ month : num 6 6 6 6 6 6 6 6 6 6 ...
$ year : num 2016 2016 2016 2016 2016 ...
$ day : num 9 9 8 8 8 8 7 7 7 7 ...
I've been doing this to extract summary statistics by station:
P303.split <- split(P303, Parameter)
Copper = P303.split$'Copper'
CopperSumStats = data.frame(do.call("rbind", by(Copper[, "Result"], Copper[,"Station"], summary)))
So now just need start and end dates... Thanks in advance!