I have a vector like this
c(\"1\", \"a\",\"b\")
and I\'d like to create this list
list(\"a\"=1,\"b\"=1)
is
Like this?
R> kn <- c("1", "a", "b") R> nl <- vector(mode="list", length=length(kn)-1) R> names(nl) <- kn[-1] R> nl <- lapply(nl, function(x) kn[1]) R> nl $a [1] "1" $b [1] "1" R>
With kudos to Gavin for spotting an earlier error.