Reputation: 21749
My question looks quite simple but I can't get my head around it.
I have a list:
f <- list(a = c(1,2,3), b = c('x','y','z'), c = c(0.1,0.2,0.3))
I want to split this list such that I get three new vectors in my environment where:
a <- c(1,2,3)
b <- c('x','y','z')
c <- c(0.1,0.2,0.3)
So that when I do print(a)
I should get c(1,2,3)
as its value and so on.
Upvotes: 0
Views: 144
Reputation: 2206
Another option would be
for (i in names(f)) {
assign(i, f[[i]])
}
Your original list will still exist in the environment. You may or may not want to remove it.
Upvotes: 1