0

我试图将两个字符串向量交错成一个向量,我相信,等号的quosures。这是一个例子:

a <- c('coef_name1', 'coef_name2')
b <- c('clean_name1', 'clean_name2')
desired_output <- c('coef_name1'='clean_name1', 'coef_name2'='clean_name2')

作为第一步,我尝试了交错,即

c(rbind(a, b))

但我有点陷入困境。我也尝试过手动创建一个简短的 quosure,但是

quo(a[1] = b[1])

不起作用(虽然它确实适用于'+')..

我需要这个,因为我想用参数 newNames 更改 coefplot::coefplot 中显示的系数名称。请参阅其文档的第 9 页:https ://cran.r-project.org/web/packages/coefplot/coefplot.pdf

那我可以做

coefplot::coefplot(model, newNames = desired_output, intercept = FALSE)
4

1 回答 1

2

coefplot文档描述newNames“系数新名称的命名字符向量”

# b is a character vector without names
b <- c('clean_name1', 'clean_name2')

# give it names
a <- c('coef_name1', 'coef_name2')
names(b) <- a
# now b is a named character vector

# so this should work
coefplot::coefplot(model, newNames = b, intercept = FALSE)
于 2019-08-14T16:38:10.123 回答