I have daily time-series data (2015, 2017, 2018) that I want to plot. The data is not complete each year as well, for example, there are missing values in February 2018. When I plot it, there is a straight line connecting every missing value.
Here is the example of data:
structure(list(station = c("NYA", "NYA", "NYA", "NYA", "NYA",
"NYA", "NYA", "NYA", "NYA", "NYA", "NYA"), date = structure(c(1505952000,
1506038400, 1506124800, 1506211200, 1519862400, 1519948800, 1520035200,
1520121600, 1520208000, 1520294400, 1520380800), tzone = "UTC", class = c("POSIXct",
"POSIXt")), yyyy = c(2017, 2017, 2017, 2017, 2018, 2018, 2018,
2018, 2018, 2018, 2018), mmm = c("Sep", "Sep", "Sep", "Sep",
"Mar", "Mar", "Mar", "Mar", "Mar", "Mar", "Mar"), dd = c(21,
22, 23, 24, 1, 2, 3, 4, 5, 6, 7), season = c("Summer", "Summer",
"Summer", "Summer", "Spring", "Spring", "Spring", "Spring", "Spring",
"Spring", "Spring"), parameter = c("pm10", "pm10", "pm10", "pm10",
"pm10", "pm10", "pm10", "pm10", "pm10", "pm10", "pm10"), concentration = c(1.18203524647271,
0.272779348785041, 2.72734710946683, 1.90901454850886, 1.36318527323721,
2.09023261562629, 2.81729052990488, 1.27222532200908, 0.999671017356097,
0.999603793405514, 1.09048875706049)), row.names = c(NA, -11L
), class = c("tbl_df", "tbl", "data.frame"))
Here is the code I use now:
ggplot(data = df2, aes(x = date, y = concentration,col=station )) +geom_line() + facet_wrap(facets = vars(parameter),scales="free",ncol=7)
You can see the result in the following image
I have several questions:
- I want to remove the straight line and remove the axis with missing value, only plot the day with value. Can I do that?
- Can I draw for a specific parameter (for example Na and Cl only)?
- How to edit label on the top of each graph?
Thank you in advance.