Suppose n dataframes within a list. Each of these dataframes has different lines. For example, in a dataframe, rownames
are characters (car brands), and, on the other, rownames
are enrollment numbers in a hospital.
My goal is to transfer each of these rownames
into its respective dataframe, as a variable, and into the list. This is:
dados$newvariable<-rownames(dados)
It's not interesting, as I have to type this for each dataframe.
dput
to aid resolution:
list(structure(list(modelo = structure(1:5, .Label = c("a", "b",
"c", "d", "e"), class = "factor"), valor = c(5000, 10000, 15000,
20000, 25000)), .Names = c("modelo", "valor"), row.names = c("Fiat",
"Chevrolet", "Volkswagen", "Renault", "Ford"), class = "data.frame"),
structure(list(convenio = structure(1:6, .Label = c("a",
"b", "c", "d", "e", "f"), class = "factor"), valor = c(150,
300, 450, 600, 750, 900)), .Names = c("convenio", "valor"
), row.names = c("17242", "60003", "50215", "54345", "11246",
"45432"), class = "data.frame"))