R - tips

加载包间接赋值报错的解决办法

2018-11-21  本文已影响0人  董八七

from Load R package from character string - Stack Overflow

例如,我想这样:

load.this <- "ggplot"
library(load.this) 

会报错'package' must be of length 1
解决方法是

load.this <- "ggplot"
library(load.this, character.only=TRUE) 
# 如果你要返回是否加载成功
library(load.this, character.only=TRUE, logical.return = T) 
上一篇下一篇

猜你喜欢

热点阅读