0

I created a list of names and a list of dataframes

i <- 1
mylist <- c()
list.dfs <- list(d0, d1, d2, d3, d4, d5, d6, d7, d8, d9)

while (i<37) {
  a <- paste("ABCD", i, sep = "")
  mylist <- c(mylist, a)
  }
  i <- i+1
}

These variables in mylist (ABCD1, ABCD2, ...) are all part of the dataframes d0:d9. Now I want to change these variables in the dataframes in a loop.

for (i in 1:length(mylist)) {
   list.dfs[[i]]$mylist[[i]] <- as.numeric(list.dfs[[i]]$mylist[[i]])
}

It says "Unknown or uninitialised column: mylist.".

However, when I run the following code, it gives me the correct names:

for (i in 1:length(mylist)) {
 print(mylist[[i]])
}
Joshua
  • 15
  • 6

0 Answers0