ggbiplot下载失败的解决方法
今天的内容本来是运用R语言进行主成分分析(PCA),结果TM第一步就卡住了,下载ggbiplot包花费了我半个下午的时间。
以下是宝贵的经验,亲测有效。如果是下载其他的包,遇到相似的问题,这个方法应该也是适用的。
1 2 3 | > install.packages("devtools") > library(devtools) > install_github("vqv/ggbiplot") |
如果你用上面的代码成功下载了,算你厉害。
而我运行的结果一直是这样的:
1 2 3 4 | library(devtools) install_github("vqv/ggbiplot") 错误: Failed to install 'unknown package' from GitHub: schannel: failed to receive handshake, SSL/TLS connection failed |
或者是这样的:
1 2 3 4 5 6 7 8 9 | 错误: (由警告转换成)程辑包'ggplot2'是用R版本3.6.3 来建造的 停止执行 ERROR: lazy loading failed for package 'ggbiplot' * removing 'C:/Program Files/R/R-3.6.2/library/ggbiplot' * restoring previous 'C:/Program Files/R/R-3.6.2/library/ggbiplot' 错误: Failed to install 'ggbiplot' from GitHub: (由警告转换成)installation of package ‘C:/Users/Administrator/AppData /Local/Temp/RtmpQhQAak/file25f448948cb /ggbiplot_0.55.tar.gz’ had non-zero exit status |
尝试了无数次依然不行。我决定去github手动下载到本地,然后再解压安装到library下。然而,结果是这样的:
1 | "ggbiplot"不是有效的已经安装了的程序包 |
就在我在苦苦寻找解决方法时,Stack Overflow里的一个问题与我现在面临的问题非常相似!我尝试了下面的一个回答,没想到居然成功了!让我哭一会…
就是这个:
1 | install.packages("C:/Users/Administrator/AppData/Local/Temp/RtmpQhQAak/file25f448948cb/ggbiplot_0.55.tar.gz", repos = NULL, type = "source") |
这里的路径就是上面提示错误的路径。复制过来就好了:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | install.packages("C:/Users/Administrator/AppData/Local/Temp/RtmpQhQAak/file25f448948cb/ggbiplot_0.55.tar.gz", repos = NULL, type = "source") * installing *source* package 'ggbiplot' ... ** using staged installation ** R ** data ** byte-compile and prepare package for lazy loading Warning messages: 1: 程辑包'ggplot2'是用R版本3.6.3 来建造的 2: 程辑包'scales'是用R版本3.6.3 来建造的 ** help *** installing help indices converting help for package 'ggbiplot' finding HTML links ... 好了 ggbiplot html ggscreeplot html wine html ** building package indices ** testing if installed package can be loaded from temporary location *** arch - i386 Warning: package 'ggplot2' was built under R version 3.6.3 Warning: package 'scales' was built under R version 3.6.3 *** arch - x64 Warning: package 'ggplot2' was built under R version 3.6.3 Warning: package 'scales' was built under R version 3.6.3 ** testing if installed package can be loaded from final location *** arch - i386 Warning: package 'ggplot2' was built under R version 3.6.3 Warning: package 'scales' was built under R version 3.6.3 *** arch - x64 Warning: package 'ggplot2' was built under R version 3.6.3 Warning: package 'scales' was built under R version 3.6.3 ** testing if installed package keeps a record of temporary installation path * DONE (ggbiplot) |
太不容易了,Stackoverflow中的回答链接:
(https://stackoverflow.com/questions/29656320/r-mvpart-package-any-option-to-use-in-r-3-1-x)
最后,加载ggbiplot,做个最简单的PCA。
1 2 | library(ggbiplot) ggbiplot(wine.pca) |
关于PCA的原理、创建视图以及具体的分析将在下一篇博客中介绍。