I am having an issue assigning variable objects to a list of data frames. For example,
df1 <- data.frame(a = 1, b = 1:10)
df2 <- data.frame(a = 2, b = 1:10)
df3 <- data.frame(a = 3, b = 1:10)
x <- c("a", "b", "c")
y <- list("df1", "df2", "df3")
My goal is to assign each data frame in the y list to the object in x. I can do it long hand.
a <- y[[1]]
But I have many iterations. I have tried the following without any luck
map2(x, y, function(x, y) x <- y)
and
map2(x, y, ~assign(x, y))
Appreciate any help!