R语言for循环绘多张图
data("diamonds")
m <- split(diamonds, diamonds$color)
length(m)
for (i in 1:length(m)) {
sub_data <- m[[i]]
#save the plot
png(filename = paste0(i, "_", ".jpg"),width = 2400,height = 1800,res = 300)
print(ggplot(data = sub_data, aes(x = carat, y = price, color = cut)) + geom_point())
dev.off()
}