2
我使用facet_wrap
到每个组图, ,但我需要保存每个情节个体并找到下面的链接。使用ggplot()每组申请group_by()
我试图在URL链接中编程答案,并可以保存PDF文件, 但提出了错误的按摩。
CODE:
iris %>% group_by(Species) %>%
do({
p <- ggplot(., aes(x =Sepal.Length, y = Petal.Length)) + geom_point()
ggsave(p, filename = paste0("fig/", unique(.$Species), ".pdf"))
})
错误消息:
Results are not data frames at positions: 1, 2, 3
网址: applying a function to the output of dplyr's group_by
'do'想要你返回一个data.frame – baptiste
也许你想'library(tidyverse); iris%>% split(。$ Species)%>%map(〜ggplot(。,aes(x = (。),〜ggsave(.x,filename = paste0(.y,“.pdf”)))'' – lukeA