Add new column to data.frame through loop in R
问题 I have n number of data.frame i would like to add column to all data.frame a <- data.frame(1:4,5:8) b <- data.frame(1:4, 5:8) test=ls() for (j in test){ j = cbind(get(j),IssueType=j) } Problem that i'm running into is j = cbind(get(j),IssueType=j) because it assigns all the data to j instead of a , b . 回答1: As commented, it's mostly better to keep related data in a list structure. If you already have the data.frames in your global environment and you want to get them into a list, you can use: