如何交错两个等号的字符串向量?
How to interleave two string vectors with equal signs?
我正在尝试将两个字符串向量交织成一个向量,我相信,向量具有等号。
这是一个例子:
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)
coefplot documentation 将 newNames
描述为 "Named character vector of new names for coefficients"
# 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)
我正在尝试将两个字符串向量交织成一个向量,我相信,向量具有等号。 这是一个例子:
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)
coefplot documentation 将 newNames
描述为 "Named character vector of new names for coefficients"
# 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)