chr
我正在尝试开发一个循环来绘制名为
desired_length <- 8
plot_list <- vector(mode = "list", length = desired_length)
for(i in 3:10) {
{lot_list[[i-2]] <- ggplot(chr) +
geom_point(data = chr, aes(x = chr[,1], y = chr[,i], color = ponto),
size = 2) +
geom_hline(yintercept = as.double(cla[1,i-1]), size = 2, linetype = "dashed", color = "black") +
ylim(0,max(chr[,i], na.rm = TRUE)) +
labs(title = glue("Resultados analíticos no corpo receptor do empto para {(colnames(chr))[i]}"),
subtitle = glue("Padrão de c3 ={cla[,i-1]} mg/L"), y = glue("{(colnames(chr))[i]} (mg/L)"), x = "Período de análise", caption = glue("Número de amostras = {sum(!is.na(chr[,i]))}")) +
theme_minimal()
}
}
如果我手动保存,例如:
plot_list[[1]] <- ggplot(chr) +
geom_point(data = chr, aes(x = chr[,1], y = chr[,3], color = ponto),
size = 2) + ...
当我跑步时它完美地绘制
plot_list[[1]]
但是当我在运行循环后运行绘图时,也使用 plot_list[ 1 ],它显示所有值都丢失并且只显示此绘图,并带有此警告消息:删除了 142 行包含缺失值(geom_point)。
可能出了什么问题?提前感谢您帮助我