R语言中的 "Error in gzfile(file, "wb") :cannot open the connection" 异常处理总结

您所在的位置:网站首页 r语言中fivenum是什么意思 R语言中的 "Error in gzfile(file, "wb") :cannot open the connection" 异常处理总结

R语言中的 "Error in gzfile(file, "wb") :cannot open the connection" 异常处理总结

2023-09-10 01:55| 来源: 网络整理| 查看: 265

R语言中的 "Error in gzfile(file, "wb") :cannot open the connection" 异常处理总结 最近学R语言做数据分析时,遇到到一个很让人头疼的问题,reshape2 包下载好了,但 Rstudio 运行后,就报出下面的红色报错异常, 说是打不开链接,画图渲染异常。具体情况如下:

> par(mfrow = c(length(colors())%/%60+1,1))

>par(mar=c(0.1,0.1,0.1,0.1),xaxs="i",yaxs="i")

> for(i in 1:(length(colors())%/%60+1)){

+ barplot(rep(1,60), col =colors()[((i-1)*60+1):(i*60)], border = colors()[((i-1)*60+1):(i*60)], axes =FALSE)

+ box() }

Error in gzfile(file, "wb") :cannot open the connection

In addition: Warning message:

In gzfile(file, "wb") :

 cannot open compressed file'C:/Users/????/AppData/Local/Temp/RtmpCuJjwT/rs-graphics-304ed13f-1958-4eeb-930a-24d61ef9cef2/7c68cc44-8d16-47cd-a3ba-93c854098270.snapshot',probable reason 'Invalid argument'

Graphics error: Plot rendering error

经过这两天的查找,突然发现用R端口运行程序时数据画图时却能正常运行,然后在结合网上资料,明白了 ”Errorin gzfile(file, "wb") :cannot open the connection“ 异常的原因和处理办法了,首先它与 window系统是64位还是32位无关,主要原因是Rstudio 这个 IDE 在含有中文路径下无法建立系统生成的临时数据画图的存储,进而无法访问到系统到snapshot文件。具体处理方法如下:

第一步:在系统用户文件夹下创建一个纯英文的temp文件路径,例如创建一个Yoong文件,然后建立一个如图中红线所示的文件路径 Yoong\AppData\Local\Temp. 这里的 “用户“ 由于是系统自动生成的,所以会自动变成 C:\Users\Yoong\... ,其中 Temp文件为空文件。

第二步,找到系统的高级设置,打开系统属性的环境变量设置,分别在个人用户环境变量中的TMEP 和 TMP 环境变量后面把上面创建的 temp 文件路径复制到这两个环境变量后面,然后,用户环境变量中的TEMP和TMP修改后如下:

TEMP : C:\Users\悠风号\AppData\Local\Temp;C:\Users\Yoong\AppData\Local\Temp

TMP : C:\Users\悠风号\AppData\Local\Temp;C:\Users\Yoong\AppData\Local\Temp

最后,再次重新打开Rstudio后,即可正常运行。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3