![](/img/trans.png)
[英]How to call several vectors into the r environment to use them in another function
[英]How to use strings stored in vectors in another function
您好,我正在尝试这个for循环,其中我在r中启用了多个库。
lbs<-c("plyr","dplyr","magrittr","readr")
for (i in 1:length(lbs)) {
library(lb[i])
}
但是我得到这个错误
Error in library(lb[i]) : 'package' must be of length 1
我的问题涉及两个dillema。
如何使用向量中存储的字符串在其他函数中使用它们?
我如何告诉rstudio每次在open r中默认启用某些库。
简而言之:
library()
函数很奇怪。 尝试library(lb[i],character.only = TRUE)
。 在?library
的最底端有一个示例说明了它的价值。 ?Startup
,特别是有关使用.Rprofile
文件的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.