【发布时间】:2025-12-19 12:25:11
【问题描述】:
以下代码
test <- c("key"=c(8, 5, 9))
结果
key1 key2 key3
8 5 9
但是,我希望输出是
key key key
8 5 9
有没有办法向 R 向量指定它不应该添加该自动索引?我目前的解决方法如下,一旦分配了“测试”,我就会调用它
names(test) <- c(rep("key", length(test)))
【问题讨论】:
-
test <- setNames(c(8, 5, 9), rep("key", 3))或使用list(),例如test <- list("key"=c(8, 5, 9))..