如何用Rstudio安装包?
启动Rstudio
点击菜单栏里的tools--global options --packages
如下图所示将镜像源设定为中国清华大学,然后点击apply,ok.
3.点击tools--install packages,填入要安装的包的名字,然后点击install,结果提示先要安装Rtools。但是通过命令library(readxl),已经能够成功载入readxl包了。
> install.packages("readxl")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
将程序包安装入‘C:/Users/LSS/Documents/R/win-library/4.1’
(因为‘lib’没有被指定)
还安装相依关系‘glue’, ‘cli’, ‘utf8’, ‘rematch’, ‘ellipsis’, ‘fansi’, ‘lifecycle’, ‘magrittr’, ‘pillar’, ‘pkgconfig’, ‘rlang’, ‘vctrs’, ‘hms’, ‘prettyunits’, ‘R6’, ‘crayon’, ‘cellranger’, ‘Rcpp’, ‘tibble’, ‘progress’
有二进制版本的,但源代码版本是后来的:
binary source needs_compilation
pillar 1.6.3 1.6.4 FALSE
rlang 0.4.11 0.4.12 TRUE
Binaries will be installed
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/glue_1.4.2.zip'
Content type 'application/zip' length 155613 bytes (151 KB)
downloaded 151 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/cli_3.0.1.zip'
Content type 'application/zip' length 761012 bytes (743 KB)
downloaded 743 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/utf8_1.2.2.zip'
Content type 'application/zip' length 209943 bytes (205 KB)
downloaded 205 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/rematch_1.0.1.zip'
Content type 'application/zip' length 16242 bytes (15 KB)
downloaded 15 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/ellipsis_0.3.2.zip'
Content type 'application/zip' length 49248 bytes (48 KB)
downloaded 48 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/fansi_0.5.0.zip'
Content type 'application/zip' length 248477 bytes (242 KB)
downloaded 242 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/lifecycle_1.0.1.zip'
Content type 'application/zip' length 123387 bytes (120 KB)
downloaded 120 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/magrittr_2.0.1.zip'
Content type 'application/zip' length 236041 bytes (230 KB)
downloaded 230 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/pkgconfig_2.0.3.zip'
Content type 'application/zip' length 22493 bytes (21 KB)
downloaded 21 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/rlang_0.4.11.zip'
Content type 'application/zip' length 1201275 bytes (1.1 MB)
downloaded 1.1 MB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/vctrs_0.3.8.zip'
Content type 'application/zip' length 1253348 bytes (1.2 MB)
downloaded 1.2 MB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/hms_1.1.1.zip'
Content type 'application/zip' length 104270 bytes (101 KB)
downloaded 101 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/prettyunits_1.1.1.zip'
Content type 'application/zip' length 37957 bytes (37 KB)
downloaded 37 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/R6_2.5.1.zip'
Content type 'application/zip' length 84230 bytes (82 KB)
downloaded 82 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/crayon_1.4.1.zip'
Content type 'application/zip' length 142398 bytes (139 KB)
downloaded 139 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/cellranger_1.1.0.zip'
Content type 'application/zip' length 105053 bytes (102 KB)
downloaded 102 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/Rcpp_1.0.7.zip'
Content type 'application/zip' length 3263140 bytes (3.1 MB)
downloaded 3.1 MB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/tibble_3.1.5.zip'
Content type 'application/zip' length 870969 bytes (850 KB)
downloaded 850 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/progress_1.2.2.zip'
Content type 'application/zip' length 85979 bytes (83 KB)
downloaded 83 KB
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/4.1/readxl_1.3.1.zip'
Content type 'application/zip' length 1717471 bytes (1.6 MB)
downloaded 1.6 MB
package ‘glue’ successfully unpacked and MD5 sums checked
package ‘cli’ successfully unpacked and MD5 sums checked
package ‘utf8’ successfully unpacked and MD5 sums checked
package ‘rematch’ successfully unpacked and MD5 sums checked
package ‘ellipsis’ successfully unpacked and MD5 sums checked
package ‘fansi’ successfully unpacked and MD5 sums checked
package ‘lifecycle’ successfully unpacked and MD5 sums checked
package ‘magrittr’ successfully unpacked and MD5 sums checked
package ‘pkgconfig’ successfully unpacked and MD5 sums checked
package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘vctrs’ successfully unpacked and MD5 sums checked
package ‘hms’ successfully unpacked and MD5 sums checked
package ‘prettyunits’ successfully unpacked and MD5 sums checked
package ‘R6’ successfully unpacked and MD5 sums checked
package ‘crayon’ successfully unpacked and MD5 sums checked
package ‘cellranger’ successfully unpacked and MD5 sums checked
package ‘Rcpp’ successfully unpacked and MD5 sums checked
package ‘tibble’ successfully unpacked and MD5 sums checked
package ‘progress’ successfully unpacked and MD5 sums checked
package ‘readxl’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\LSS\AppData\Local\Temp\Rtmp46zJLe\downloaded_packages
安装源码包‘pillar’
trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/pillar_1.6.4.tar.gz'
Content type 'application/octet-stream' length 1097062 bytes (1.0 MB)
downloaded 1.0 MB
* installing *source* package 'pillar' ...
** package 'pillar' successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'pillar'
finding HTML links ... done
align html
char html
colonnade html
ctl_new_pillar html
deprecated html
dim_desc html
expect_known_display html
extra_cols html
format_glimpse html
format_tbl html
format_type_sum html
get_extent html
glimpse html
new_ornament html
finding level-2 HTML links ... done
new_pillar html
new_pillar_component html
new_pillar_shaft html
new_pillar_title html
new_pillar_type html
new_tbl_format_setup html
num html
pillar-package html
pillar html
pillar_options html
pillar_shaft html
squeeze html
style_subtle html
tbl_format_body html
tbl_format_footer html
tbl_format_header html
tbl_format_setup html
tbl_sum html
type_sum html
*** copying figures
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (pillar)
The downloaded source packages are in
‘C:\Users\LSS\AppData\Local\Temp\Rtmp46zJLe\downloaded_packages’
4.安装Rtools
A.安装并载入 installr stringr两个包
install.packages("installr")
install.packages("stringr") ###依赖包
library(stringr)
library(installr)
B.运行下面一行代码
install.Rtools(page_with_download_url = "<a href="https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/Rtools/")">https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/Rtools/")
> install.Rtools(page_with_download_url = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/Rtools/")
将程序包安装入‘C:/Users/LSS/Documents/R/win-library/4.1’
(因为‘lib’没有被指定)
还安装相依关系‘ps’, ‘processx’, ‘callr’, ‘desc’, ‘rprojroot’, ‘withr’
结果安装半截给出了如下提示
C:\Users\LSS\AppData\Local\Temp\Rtmp46zJLe/rtools40-x86_64.exe
Running the installer now...
You'll need to go to the site and download this yourself. I'm now going to try and open the url for you.
Error in system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait, :
unused argument (page_with_download_url = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/Rtools/")
In addition: Warning message:
In download_fun(exe_URL, destfile = exe_filename, quiet = FALSE, :
downloaded length 54935552 != reported length 179358544
并弹出了一个网址
https://cran.r-project.org/bin/windows/Rtools/
看来我们只能手动下载安装了。下载完成之后如下图
右键点击,选择以管理员身份运行
弹出来你要允许此应用对你的设备进行更改吗,选择是
然后设定好安装路径点击next
然后保持默认设定点击next
然后点击install
然后点击finish
可以看到rtools40已经安装好了。
接下来是配置环境变量把rtools40的安装路径添加到环境变量path里面
如何配置path环境变量的学习可以看帖子https://www.cda.cn/discuss/post/details/6049758b75777523b5dff661








暂无数据