applying a function to the output of dplyr's group_by

后端 未结 1 1784
粉色の甜心
粉色の甜心 2020-12-19 18:54

I would like to subset a large dataframe and create a ggplot of each grouping. Sounds like a perfect candidate for dplyr but I\'m running into issues calling functions on th

相关标签:
1条回答
  • 2020-12-19 18:58

    Well, you have a parenthesis problem and a file naming problem so maybe it's one of those that you are referring to. I'm assuming

    iris %>%
      group_by(Species) %>%
      do({
          p <- ggplot(., aes(x=Sepal.Length, y=Sepal.Width)) + geom_point()
          ggsave(p, filename=paste0(unique(.$Species),".pdf"))
         })
    

    would fix your problem.

    0 讨论(0)
提交回复
热议问题