在此示例中:
> s <- letters[1:3]
> L <- lapply(s,rep,5)
> L
[[1]]
[1] "a" "a" "a" "a" "a"
[[2]]
[1] "b" "b" "b" "b" "b"
[[3]]
[1] "c" "c" "c" "c" "c"
如何用s的对应元素命名L的元素?
我想拥有的是:
> L
[["a"]]
[1] "a" "a" "a" "a" "a"
[["b"]]
[1] "b" "b" "b" "b" "b"
[["c"]]
[1] "c" "c" "c" "c" "c"
编辑:在我的情况下s非常大,因此没有手动解决方案。我宁愿在创建L时或之后立即命名L的元素。