Using dplyr for exploratory plots

时光怂恿深爱的人放手 提交于 2019-12-03 08:38:45

I believe you can work with do for this task with the same function you used in d_ply. It will print directly to the plotting window, but also saves the plots as a list within the resulting data.frame if you use a named argument (see help page, this is essentially like using dlply). I don't fully grasp all that do can do, but if I don't use a named argument I get an error message but the plots still print to the plotting window (in RStudio).

plot_species <- function(species_data){
  p <- qplot(data=species_data,
        x=Sepal.Length,
        y=Sepal.Width)
  print(p)

}

group_by(iris, Species) %>%
    do(plot = plot_species(.))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!