Gglot for time series of many, many lines?

Here is my solution, using do() with group_by

  1. Make a function that returns a dataframe with 10 rows and 21 columns.
get_quantiles <- function(x) {
	values <- x$rainfall_per_square_meter
	t = quantile(values, seq(.1,.9,.1))
	df <- data.frame(quantile_value = t, quantile = seq(.1,.9,.1))
	return(df)
}
  1. Use group_by with do() to make an output dataframe that has get_quantiles mapped across years and appended.
df2 <- df %>% group_by(year) %>%
do(get_quantiles(.))

Next steps are to make my get_quantiles function more extensible to use different variables and sets of quantiles.

My new plot now looks like this:

1 Like