R ggplotly赢得';无法工作或重新安装-有办法卸载它吗?

R ggplotly赢得';无法工作或重新安装-有办法卸载它吗?,r,R,我有一个问题,我想我可能能够解决我的问题,如果我可以在尝试重新安装之前卸载“ggplotly” 发生的事情如下: 当讲师演示时,代码运行良好,当我在家尝试时失败。那是R·马克。逐行调查问题代码单元格,问题集中在ggplot2(使用ggplotly)。下面提供了代码和错误消息。在代码“图形”中有一个ggplot2 facet\u wrap(),它应该传递到ggplotly 以下是从我的控制台中摘录的问题,以及通过重新安装修复该问题的失败尝试: > ggplotly(graph) Error

我有一个问题,我想我可能能够解决我的问题,如果我可以在尝试重新安装之前卸载“ggplotly”

发生的事情如下:

当讲师演示时,代码运行良好,当我在家尝试时失败。那是R·马克。逐行调查问题代码单元格,问题集中在
ggplot2
(使用
ggplotly
)。下面提供了代码和错误消息。在代码“图形”中有一个
ggplot2 facet\u wrap()
,它应该传递到
ggplotly

以下是从我的控制台中摘录的问题,以及通过重新安装修复该问题的失败尝试:

> ggplotly(graph)
Error in dev_fun(tmpPlotFile, width = deviceWidth, height = deviceHeight) : 
  unable to start png() device
> ggplotly(graph)
Error in RStudioGD() : 
  Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning messages:
1: In grDevices:::png("C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png",  :
  unable to open file 'C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png' for writing
2: In grDevices:::png("C:/Users/User/AppData/Local/Temp/Rtmp0ar20f/3b613ba7d0ce4228bc937aee7cfcb112.png",  :
  opening device failed
> install.packages("plotly")
Error in install.packages : Updating loaded packages
Error in gzfile(file, mode) : cannot open the connection
In addition: Warning message:
In gzfile(file, mode) :
  cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory

根据此线程上的注释,可以使用
remove.packages
卸载软件包。根据这篇文章的原始问题,卸载和重新安装清除了它,但为了完整性,我采取了以下所有预防措施来提高这篇文章的成功率:

  • 如图所示卸下包装
  • 重新初始化RStudio(退出而不保存工作区并重新输入)
  • 默认情况下,它会记住我的一些环境,因此我单击了扫帚图标以清除内存中的所有变量和数据
  • 重新安装包
  • 重新加载原始R文件并进行测试,以确保所有文件均按预期工作
  • 这是我在控制台中看到的,与原始帖子中显示的消息相比,我在控制台中看到了卸载和重新安装:

    在卸载过程中:

    > remove.packages("plotly")
    Removing package from ‘C:/ProgramFilesCoders/R/R-3.3.2/library’
    (as ‘lib’ is unspecified)
    Error in gzfile(file, mode) : cannot open the connection
    In addition: Warning message:
    In gzfile(file, mode) :
      cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
    
    > install.packages("plotly")
    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/plotly_4.5.6.zip'
    Content type 'application/zip' length 817502 bytes (798 KB)
    downloaded 798 KB
    
    package ‘plotly’ successfully unpacked and MD5 sums checked
    
    The downloaded binary packages are in
        C:\Users\User\AppData\Local\Temp\RtmpGco6OK\downloaded_packages 
    
    重新安装期间:

    > remove.packages("plotly")
    Removing package from ‘C:/ProgramFilesCoders/R/R-3.3.2/library’
    (as ‘lib’ is unspecified)
    Error in gzfile(file, mode) : cannot open the connection
    In addition: Warning message:
    In gzfile(file, mode) :
      cannot open compressed file 'C:\Users\User\AppData\Local\Temp\Rtmp0ar20f/libloc_190_4464fd2b.rds', probable reason 'No such file or directory'
    
    > install.packages("plotly")
    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/plotly_4.5.6.zip'
    Content type 'application/zip' length 817502 bytes (798 KB)
    downloaded 798 KB
    
    package ‘plotly’ successfully unpacked and MD5 sums checked
    
    The downloaded binary packages are in
        C:\Users\User\AppData\Local\Temp\RtmpGco6OK\downloaded_packages 
    

    您可以使用功能
    remove.packages
    删除已安装的软件包,谢谢!成功了。很快就会在完整答案中发布。