Stephen HK Wong
2014-10-15 20:28:24 UTC
Dear All,
I have many 50 objects they are all dataframes. Each dataframe has many rows and four column. I simply want to do an addition of 3rd and 4th column and save the result into 5th column. Since there are many dataframes, I don't want to do it one by one, is there a way to loop through all objects and perform the similar action ?
One way I can think of is like this:
for (i in 1:50){
get(ls()[i])[,3]+get(ls()[i][,4]
}
But I don't know how to save the addition result back to 5th column of each dataframe.
Many Thanks!
Stephen HK Wong
I have many 50 objects they are all dataframes. Each dataframe has many rows and four column. I simply want to do an addition of 3rd and 4th column and save the result into 5th column. Since there are many dataframes, I don't want to do it one by one, is there a way to loop through all objects and perform the similar action ?
One way I can think of is like this:
for (i in 1:50){
get(ls()[i])[,3]+get(ls()[i][,4]
}
But I don't know how to save the addition result back to 5th column of each dataframe.
Many Thanks!
Stephen HK Wong