In this example:
> 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"
How can I name the elements of L by the corresponding element of s?
What I would like to have is:
> L
[["a"]]
[1] "a" "a" "a" "a" "a"
[["b"]]
[1] "b" "b" "b" "b" "b"
[["c"]]
[1] "c" "c" "c" "c" "c"
Edit: in my case s is very large, so no manual solution. I would prefer to name the elements of L at the moment of creating L, or immediately after.