【发布时间】:2019-11-18 08:15:49
【问题描述】:
我想粘贴一个命名向量和一个字符串。有没有办法保留名字?
named <- c(first = "text 1", second = "text 2")
description <- c("description 1", "description 2")
预期结果是:
setNames(paste(named, description), names(named))
> first second
"text 1 description 1" "text 2 description 2"
但它是多余的,因为名称已经在向量中。是否有其他方法可以保留名称而不重复访问变量?
paste(named, description)
> "text 1 description 1" "text 2 description 2"
【问题讨论】: