Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在循环中绘制错误_R_Ggplot2 - Fatal编程技术网

R 在循环中绘制错误

R 在循环中绘制错误,r,ggplot2,R,Ggplot2,大家好,我正在尝试从csv文档导入多个数据站,然后将它们的信息打印到一个循环中。 我想将我的信息虚拟存储在R中,以便对它们进行操作。此外,我需要找到一种方法来显示矩阵中的所有绘图。最后是另一张只有一张图的表格,它描绘了我所有的数据站。我希望你能帮助我 我的数据只有两列,日期和深度如下: ldat <- lapply(1:18, function(x) data.table(Date = sample(seq(as.Date('2016/01/01'), as.Date('2016/01/3

大家好,我正在尝试从csv文档导入多个数据站,然后将它们的信息打印到一个循环中。 我想将我的信息虚拟存储在R中,以便对它们进行操作。此外,我需要找到一种方法来显示矩阵中的所有绘图。最后是另一张只有一张图的表格,它描绘了我所有的数据站。我希望你能帮助我

我的数据只有两列,日期和深度如下:

ldat <- lapply(1:18, function(x) data.table(Date = sample(seq(as.Date('2016/01/01'), as.Date('2016/01/31'), by="day"), 12),
                                        Deep = runif(12, min = 32, max = 100)))

ldat将所有数据读取到一个数据帧中,然后阅读我认为您需要将迭代器放在双方括号中,这样它就是rutas[[I]]。试试看。
as.numeric(tabla$Deep)
不会改变你的data.frame。为此,您需要
tabla$Deep
rutas<-list.files()
length(rutas)
par(mfrow=c(length(rutas), 2))
for (i in 1:length(rutas)) {
tabla<-read.csv(rutas[i],header=T,sep=";", as.is = TRUE,stringsAsFactors=FALSE)
as.numeric(tabla$Deep)
with(tabla, dmy_hm(Date))
a<-ggplot(tabla)+
  aes(x = as.Date(Date), y = Deep) + geom_point(colour="blue") +
  scale_x_date(labels=date_format("%Y-%m"),breaks = pretty_breaks(25)) +
  scale_y_continuous(breaks = scales::pretty_breaks(n = 10))+
  ggtitle(rutas[i]) +
  xlab("Date") + ylab("Deep m")+
  theme(axis.text.x = element_text(angle = 90, hjust = 1))
a}
"Error in: "$<-.data.frame`(*tmp*, "Deep", value = numeric(0)) : 
  replacement has 0 rows, data has 65713"