每次重新启动R会话时,除了默认的包外,我还想安装额外的软件包。
我尝试过这样的方法:选项(HTTPUserAgent= sprintf("R/%s (%s)",getRversion(),粘贴(getRversion(),R.version$platform,R.version$arch,R.version$os )) install.packages( 'shinydashboard',‘shinyWidget’,'rlist','sortable','tidyverse','XML','DescTools',‘巧妙’,‘传单’,'tidyquant','umap‘)
和这个选项(defaultPackages= c(getOption("defaultPackages"),"tidyquant",.))两者都不起作用。如果我想要做的就是在重新启动R会话时安装tidyquant包,那么如何让它在Rprofile文件中工作呢?
发布于 2022-06-09 00:18:02
我肯定会采纳@dirk-eddelbuettel对此的建议(XY problem),但如果将其添加到.Rprofile中是可能的:
.First <- function(){
utils::install.packages("tidyquant", repos="https://cran.csiro.au/")
library(tidyquant)
}(此命令在加载任何包之前运行,因此您需要指定来自utils的install.packages函数)。
不确定这是否适用于windows;我的系统信息:
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.4
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] graphics grDevices utils datasets stats methods
[7] base
other attached packages:
[1] tidyquant_1.0.4 quantmod_0.4.20
[3] TTR_0.24.3 PerformanceAnalytics_2.0.4
[5] xts_0.12.1 zoo_1.8-10
[7] lubridate_1.8.0
loaded via a namespace (and not attached):
[1] magrittr_2.0.3 tidyselect_1.1.2 munsell_0.5.0
[4] colorspace_2.0-3 lattice_0.20-45 R6_2.5.1
[7] rlang_1.0.2 quadprog_1.5-8 fansi_1.0.3
[10] dplyr_1.0.9 httr_1.4.3 tcltk_4.1.3
[13] tools_4.1.3 grid_4.1.3 gtable_0.3.0
[16] utf8_1.2.2 DBI_1.1.2 cli_3.3.0
[19] ellipsis_0.3.2 assertthat_0.2.1 tibble_3.1.7
[22] lifecycle_1.0.1 crayon_1.5.1 purrr_0.3.4
[25] ggplot2_3.3.6 vctrs_0.4.1 curl_4.3.2
[28] Quandl_2.11.0 glue_1.6.2 compiler_4.1.3
[31] pillar_1.7.0 generics_0.1.2 scales_1.2.0
[34] jsonlite_1.8.0 pkgconfig_2.0.3
> 注意:相应地选择你的克里恩镜子(除非你碰巧也在澳大利亚):https://cran.r-project.org/mirrors.html
https://stackoverflow.com/questions/72552503
复制相似问题