我正在使用R版本3.0.2中的ncdf库。我试图反复打开和关闭一些netcdf文件(我可以解释为什么,但这不是这个问题所需要的)。
sapply(1:14000, function(whatever) {
print(whatever)
sapply(prediction.cdfs, function(cdf) {
print(file.path(cdf.dir, cdf))
nc = open.ncdf(file.path(cdf.dir, cdf))
close.ncdf(nc)
})
})
在反复打开和关闭之后,它最终会因为这个错误而失败:
[1] 3329
[1] "/opt/devel/cdfs/file_one.cdf"
[1] "/opt/devel/cdfs/file_two.cdf"
[1] "/opt/devel/cdfs/file_three.cdf"
[1] "/opt/devel/cdfs/file_four.cdf"
[1] "/opt/devel/cdfs/file_five.cdf"
Error in open.ncdf(file.path(cdf.dir, cdf)) :
NAs in foreign function call (arg 1)
有人知道发生了什么吗?这个错误似乎是随机的。它发出有关外部函数调用的警报时的时间是可变的。我正在寻找解释或者一个解决方法?
谢谢。
options(error=recover)
,然后运行代码,当错误将您带入浏览器时,请进行调试。 - Josh O'Brien