r - 文件错误:无法打开 R 项目中文件的连接
问题描述
我最近开始使用 R 项目来组织我的文件和数据。
我的 .Rdata 文件和脚本都保存在同一个文件夹中(当前被选为我的工作目录)。在 RStudio 中,我可以看到全局环境中的所有对象,并且可以在该窗口中与它们进行交互,但是当我尝试运行使用其中一个对象的代码行时,会出现以下错误:
> head(current.clim)
Error in file(fn, "rb") : cannot open the connection
In addition: Warning message:
In file(fn, "rb") :
cannot open file 'C:\Users\username\AppData\Local\Temp\RtmpkVd7Cc\raster\r_tmp_2020-02-06_100056_20448_29146.gri': No such file or directory
我不明白为什么它会引用临时文件(或者为什么这些文件根本保存在这里)。R项目背后的想法不是将所有这些信息集中在一个地方吗?
任何帮助将非常感激!
编辑:
> str(current.clim)
Formal class 'RasterStack' [package "raster"] with 11 slots
..@ filename: chr ""
..@ layers :List of 2
.. ..$ :Formal class 'RasterLayer' [package "raster"] with 12 slots
.. .. .. ..@ file :Formal class '.RasterFile' [package "raster"] with 13 slots
.. .. .. .. .. ..@ name : chr "C:\\Users\\username\\AppData\\Local\\Temp\\RtmpkVd7Cc\\raster\\r_tmp_2020-02-06_100056_20448_29146.grd"
.. .. .. .. .. ..@ datanotation: chr "INT2S"
.. .. .. .. .. ..@ byteorder : Named chr "little"
.. .. .. .. .. .. ..- attr(*, "names")= chr "value"
.. .. .. .. .. ..@ nodatavalue : num -32768
.. .. .. .. .. ..@ NAchanged : logi TRUE
.. .. .. .. .. ..@ nbands : int 19
.. .. .. .. .. ..@ bandorder : Named chr "BIL"
.. .. .. .. .. .. ..- attr(*, "names")= chr "value"
.. .. .. .. .. ..@ offset : int 0
.. .. .. .. .. ..@ toptobottom : logi TRUE
.. .. .. .. .. ..@ blockrows : int 0
.. .. .. .. .. ..@ blockcols : int 0
.. .. .. .. .. ..@ driver : chr "raster"
.. .. .. .. .. ..@ open : logi FALSE
.. .. .. ..@ data :Formal class '.SingleLayerData' [package "raster"] with 13 slots
.. .. .. .. .. ..@ values : logi(0)
.. .. .. .. .. ..@ offset : num 0
.. .. .. .. .. ..@ gain : num 1
.. .. .. .. .. ..@ inmemory : logi FALSE
.. .. .. .. .. ..@ fromdisk : logi TRUE
.. .. .. .. .. ..@ isfactor : logi FALSE
.. .. .. .. .. ..@ attributes: list()
.. .. .. .. .. ..@ haveminmax: logi TRUE
.. .. .. .. .. ..@ min : num -278
.. .. .. .. .. ..@ max : num 319
.. .. .. .. .. ..@ band : int 1
.. .. .. .. .. ..@ unit : chr ""
.. .. .. .. .. ..@ names : chr "layer.1"
.. .. .. ..@ legend :Formal class '.RasterLegend' [package "raster"] with 5 slots
.. .. .. .. .. ..@ type : chr(0)
.. .. .. .. .. ..@ values : logi(0)
.. .. .. .. .. ..@ color : logi(0)
.. .. .. .. .. ..@ names : logi(0)
.. .. .. .. .. ..@ colortable: logi(0)
.. .. .. ..@ title : chr(0)
.. .. .. ..@ extent :Formal class 'Extent' [package "raster"] with 4 slots
.. .. .. .. .. ..@ xmin: num -180
.. .. .. .. .. ..@ xmax: num 180
.. .. .. .. .. ..@ ymin: num -60
.. .. .. .. .. ..@ ymax: num 90
.. .. .. ..@ rotated : logi FALSE
.. .. .. ..@ rotation:Formal class '.Rotation' [package "raster"] with 2 slots
.. .. .. .. .. ..@ geotrans: num(0)
.. .. .. .. .. ..@ transfun:function ()
.. .. .. ..@ ncols : int 8640
.. .. .. ..@ nrows : int 3600
.. .. .. ..@ crs :Formal class 'CRS' [package "sp"] with 1 slot
.. .. .. .. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
.. .. .. ..@ history : list()
.. .. .. ..@ z : list()
.. ..$ :Formal class 'RasterLayer' [package "raster"] with 12 slots
.. .. .. ..@ file :Formal class '.RasterFile' [package "raster"] with 13 slots
.. .. .. .. .. ..@ name : chr "C:\\Users\\username\\AppData\\Local\\Temp\\RtmpkVd7Cc\\raster\\r_tmp_2020-02-06_100056_20448_29146.grd"
.. .. .. .. .. ..@ datanotation: chr "INT2S"
.. .. .. .. .. ..@ byteorder : Named chr "little"
.. .. .. .. .. .. ..- attr(*, "names")= chr "value"
.. .. .. .. .. ..@ nodatavalue : num -32768
.. .. .. .. .. ..@ NAchanged : logi TRUE
.. .. .. .. .. ..@ nbands : int 19
.. .. .. .. .. ..@ bandorder : Named chr "BIL"
.. .. .. .. .. .. ..- attr(*, "names")= chr "value"
.. .. .. .. .. ..@ offset : int 0
.. .. .. .. .. ..@ toptobottom : logi TRUE
.. .. .. .. .. ..@ blockrows : int 0
.. .. .. .. .. ..@ blockcols : int 0
.. .. .. .. .. ..@ driver : chr "raster"
.. .. .. .. .. ..@ open : logi FALSE
.. .. .. ..@ data :Formal class '.SingleLayerData' [package "raster"] with 13 slots
.. .. .. .. .. ..@ values : logi(0)
.. .. .. .. .. ..@ offset : num 0
.. .. .. .. .. ..@ gain : num 1
.. .. .. .. .. ..@ inmemory : logi FALSE
.. .. .. .. .. ..@ fromdisk : logi TRUE
.. .. .. .. .. ..@ isfactor : logi FALSE
.. .. .. .. .. ..@ attributes: list()
.. .. .. .. .. ..@ haveminmax: logi TRUE
.. .. .. .. .. ..@ min : num 0
.. .. .. .. .. ..@ max : num 10577
.. .. .. .. .. ..@ band : int 12
.. .. .. .. .. ..@ unit : chr ""
.. .. .. .. .. ..@ names : chr "layer.12"
.. .. .. ..@ legend :Formal class '.RasterLegend' [package "raster"] with 5 slots
.. .. .. .. .. ..@ type : chr(0)
.. .. .. .. .. ..@ values : logi(0)
.. .. .. .. .. ..@ color : logi(0)
.. .. .. .. .. ..@ names : logi(0)
.. .. .. .. .. ..@ colortable: logi(0)
.. .. .. ..@ title : chr(0)
.. .. .. ..@ extent :Formal class 'Extent' [package "raster"] with 4 slots
.. .. .. .. .. ..@ xmin: num -180
.. .. .. .. .. ..@ xmax: num 180
.. .. .. .. .. ..@ ymin: num -60
.. .. .. .. .. ..@ ymax: num 90
.. .. .. ..@ rotated : logi FALSE
.. .. .. ..@ rotation:Formal class '.Rotation' [package "raster"] with 2 slots
.. .. .. .. .. ..@ geotrans: num(0)
.. .. .. .. .. ..@ transfun:function ()
.. .. .. ..@ ncols : int 8640
.. .. .. ..@ nrows : int 3600
.. .. .. ..@ crs :Formal class 'CRS' [package "sp"] with 1 slot
.. .. .. .. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
.. .. .. ..@ history : list()
.. .. .. ..@ z : list()
..@ title : chr(0)
..@ extent :Formal class 'Extent' [package "raster"] with 4 slots
.. .. ..@ xmin: num -180
.. .. ..@ xmax: num 180
.. .. ..@ ymin: num -60
.. .. ..@ ymax: num 90
..@ rotated : logi FALSE
..@ rotation:Formal class '.Rotation' [package "raster"] with 2 slots
.. .. ..@ geotrans: num(0)
.. .. ..@ transfun:function ()
..@ ncols : int 8640
..@ nrows : int 3600
..@ crs :Formal class 'CRS' [package "sp"] with 1 slot
.. .. ..@ projargs: chr "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
..@ history : list()
..@ z : list()
解决方案
推荐阅读
- tensorflow - MASK-RCNN 的标记数据集:只有观察良好的对象?
- linq - 在超过 14 个条目的列表中使用包含时,mobileservicesynctable pullasync 失败
- racket - 合同可以匹配吗?
- python - 为什么枕头将图像加载为矩形而不是圆形?
- javascript - JSON.stringify 带有键的对象,子对象中没有引号
- linux - 在 Linux 上确定自进程启动以来的时间
- django - django csv import-export 的外键不匹配错误
- html - 在 Bootstrap 网格中安排响应式图像视图
- android - 如何更改 Termux 中的默认启动文件夹?
- python - 在 Pandas 中为一个索引分配多行