In R it is better to save data.frames in list . If we really need to update the data.frames objects in the global environment, use list2env after transform , using "df_list" with the column "value".
df_list <- mget(ls(pattern='df\\d+')) res <- lapply(df_list, transform, value = 0.12*a + 0.24*b + 0.56*c) list2env(res, envir = .GlobalEnv) df1 # abcd value #1 1 2 3 4 2.28 #2 1 2 3 4 2.28 #3 1 2 3 4 2.28 df2 # abcd value #1 1 2 3 4 2.28 #2 1 2 3 4 2.28 #3 1 2 3 4 2.28 #4 1 2 3 4 2.28
We get the row values ( ls(pattern='df\\d+')) ) in list using mget , then scroll through the list from data.frame ( lapply(df_list, ... ), transform to create a new column 'value' in each of data.frame and finally update the objects in the global environment using list2env .
data
df1 <- structure(list(a = c(1L, 1L, 1L), b = c(2L, 2L, 2L), c = c(3L, 3L, 3L), d = c(4L, 4L, 4L)), .Names = c("a", "b", "c", "d"), class = "data.frame", row.names = c(NA, -3L)) df2 <- structure(list(a = c(1L, 1L, 1L, 1L), b = c(2L, 2L, 2L, 2L), c = c(3L, 3L, 3L, 3L), d = c(4L, 4L, 4L, 4L)), .Names = c("a", "b", "c", "d"), row.names = c(NA, -4L), class = "data.frame")