r - 在 R 中,如何设置对象的名称并在一行中返回它?

标签 r names

我想设置我的 R 对象的名称并在一行中返回它。它应该看起来像:

names(doWork(), c("a", "b", "c"))

并执行相当于:
x <- doWork()

names(x) <- c("a", "b", "c")

x

这可能吗?

最佳答案

你可以试试setNames

x <- setNames(doWork(), letters[1:3])

关于r - 在 R 中,如何设置对象的名称并在一行中返回它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29990033/

相关文章:

用加法替换字符串的数字部分

web-config - Sitecore:有效的项目名称

r - R 包的函数命名

r - Shiny 的变化 slider 动画速度

r - 迭代预测动态模型

使用数据框按键重命名列表元素

r - 如何使用dplyr :mutate to mulitply pairs of columns specified by parts of the variable name

jsf - f :facet - there is a list of predefined names attributes?

r - 在 renderPlot 之外的 Shiny 中为 renderTable 提供一个对象

r - 如何合并2个数据框以填充R中的缺失值?