我不认为
geom_qq
设置为处理每个方面具有不同的参数,因此这样做的方法可能是为数据的每个子集单独生成一个图并将它们与类似的东西组合
cowplot::plot_grid
:
library(tidyverse)
plots = df %>%
group_by(a) %>%
mutate(deg_free = MASS::fitdistr(b, “t”)$estimate[“df”]) %>%
# This second group_by is just used to keep the deg_free value
# in the final dataframe, could be removed
group_by(a, deg_free) %>%
do(
plot = ggplot(data=., aes(sample=b)) +
geom_qq(distribution = qt, dparams = list(.$deg_free)) +
geom_qq_line(distribution = qt, dparams = list(.$deg_free)) +
ggtitle(.$a)
)
Using map to unpack the list-column into a list, there’s
probably a better way
cowplot::plot_grid(plotlist=map(plots$plot, ~ .))
</code>
示例输出: