我希望使用相同的ggplot代码根据数据框中的条件生成8个不同的图形。通常我会使用facet_grid,但在这种情况下,我想要得到每个单独图形的pdf文件。例如,我希望为此处的每一行都有一个pdf:
df <- read.table(text = "
xvalue yvalue location planting crop
1 5 A early corn
2 3 A late corn
6 2 A early soy
7 4 A late soy
4 7 S early corn
2 6 S late corn
3 2 S early soy
5 1 S late soy
", sep = "", header = TRUE)
基本ggplot:
library(ggplot2)
ggplot()+
geom_point(aes(x=xvalue, y=yvalue), data=df)
但是,我不想使用facet_grid
来获取位置x种植x作物组合,我希望得到每个组合的单独pdf文件。