【发布时间】:2021-08-04 17:52:38
【问题描述】:
我想在列表中重命名我的列表名称。
例如:
library(randNames) #using this package for the random names for the example
my_info <- rand_names(10)
my_second_info <- rand_names(10)
list1 <- list(A = c(my_info$name.first), B = c(rnorm(1:10)), C = c(rnorm(1:10)), D = c(rnorm(1:10)))
list2 <- list(A = c(my_second_info$name.first), B = c(rnorm(1:10)), C = c(rnorm(1:10)), D = c(rnorm(1:10)))
both_lists <- list(list1,list2)
现在,当我调用 both_lists 时,我将 [[1]] 作为第一个列表的名称,将 [[2]] 作为第二个列表的名称 (as depicted here)。
我想将 list1 和 list2 的名称(以及可能添加到其中的所有其他名称)更改为名字随机名称。因此,列表 1 将命名为 both_lists[[1]]$A[1],而列表 2 将命名为 both_lists[[2]]$A[1]。
这可能吗?或者列表名称是否会丢失,例如在制作列表时,它只是变成一个特定的数字?
【问题讨论】: