我正在尝试将ts数据除以年份进行比较。
问题是我无法弄清楚如何强制ggplot跳过每个情节上缺少的日期。
我的数据结构如下:
> head(pmWaw)
date stacja pm25 pm10 season year month
1 2014-01-01 00:00:00 MzWarNiepodKom 100 122 winter (DJF) 2014 1
2 2014-01-01 00:00:00 MzWarszUrsynow 63 68 winter (DJF) 2014 1
3 2014-01-01 00:00:00 MzWarTarKondra NA 79 winter (DJF) 2014 1
4 2014-01-01 01:00:00 MzWarNiepodKom 69 77 winter (DJF) 2014 1
5 2014-01-01 01:00:00 MzWarszUrsynow 36 38 winter (DJF) 2014 1
6 2014-01-01 01:00:00 MzWarTarKondra NA 90 winter (DJF) 2014 1
> tail(pmWaw)
date stacja pm25 pm10 season year month
52483 2015-12-30 22:00:00 MzWarAlNiepo 36 47 winter (DJF) 2015 12
52484 2015-12-30 22:00:00 MzWarKondrat 26 29 winter (DJF) 2015 12
52485 2015-12-30 22:00:00 MzWarWokalna 36 44 winter (DJF) 2015 12
52486 2015-12-30 23:00:00 MzWarAlNiepo 39 59 winter (DJF) 2015 12
52487 2015-12-30 23:00:00 MzWarKondrat 36 39 winter (DJF) 2015 12
52488 2015-12-30 23:00:00 MzWarWokalna 40 49 winter (DJF) 2015 12
我想出的ggplot2代码是:
pmWaw %>%
ggplot(aes(x=date, y=pm25)) +
geom_jitter(alpha=0.5) +
geom_smooth() +
facet_wrap( ~ year)
结果情节每年都有差距我想删除,但无法弄清楚如何:
答案 0 :(得分:1)
在scales = 'free_x'
facet_wrap
像这样
pmWaw %>%
ggplot(aes(x=date, y=pm25)) +
geom_jitter(alpha=0.5) +
geom_smooth() +
facet_wrap( ~ year, scales = "free_x")