I have a vector like this
c(\"1\", \"a\",\"b\")
and I\'d like to create this list
list(\"a\"=1,\"b\"=1)
is
It isn't an apply style, but a simple function to wrap the required commands is:
makeList <- function(vec) {
len <- length(vec[-1])
out <- as.list(rep(as.numeric(vec[1]), len))
names(out) <- as.character(vec[-1])
out
}
Using your vector, it gives:
> vec <- c("1", "a","b")
> makeList(vec)
$a
[1] 1
$b
[1] 1