I was trying to plot the max values from a dataset with x-axis = Date
and the y-axis = max_value
grouped by Stations, like the picture I found on this link, but I would like to make 5 plots (from different Stations).
This is a sample of my df:
df2 <- data.frame (Station = c(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 10, 10, 10),
Date = c("1/1/2018", "2/1/2018", "3/1/2018","1/1/2018", "2/1/2018", "3/1/2018","1/1/2018", "2/1/2018", "3/1/2018","1/1/2018", "2/1/2018", "3/1/2018","1/1/2018", "2/1/2018", "3/1/2018"),
MAX_NO2 = c(55,52,58,76,98,12,14,23,54,76,90,99,43,32,76),
MAX_O3 = c(13,45,87,72,54,88,102,63,64,53,87,123,15,76,34))
This is the code I have:
library(tidyverse)
library(lubridate)
# your data
df2 %>%
# add date as date
mutate(date = ymd(Date)) %>%
# plot them
ggplot( aes(x = date, y = MAX_NO2 , color = Station==1, group = Station==1)) +
geom_line() + geom_point() + theme_test()
But this is what I am plotting (this is from all the dataframe, not the sample):
Where the blue dots are the max values from the Station Nº1.That's the only thing I want to plot, not the other ones in the same plot. In plot 1 Station 1, in plot 2 Station 2, etc.