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() }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/211290.html原文链接:https://javaforall.net
