你是说画出逐年平均值吗?
Base R 方案:
years <- unique(floor(time(co2)))
co2_matrix <- matrix(co2, ncol = 12, byrow = TRUE)
co2_annual <- apply(co2_matrix, 1, mean)
plot(years, co2_annual)
Tidyverse 方案:
require(tidyverse)
data.frame(c = co2, time = time(co2)) %>%
mutate(year = floor(time)) %>%
group_by(year) %>%
summarise(c = mean(c)) %>%
ggplot() +
geom_point(aes(year, c))