loops - Data manipulation on multiple dataframes in R -
suppose have dataframes a_january, a_february, a_december etc 10 columns each...
all of them have same 10 columns.. need data manipulation on 1 of 10 columns , produce new bunch of columns in each of data frames.. can manually dataframes, have 400 such dataframes..
how do this?. please let me know... suppose, need same set of operations on multiple dataframes...(create new variables, sort them etc etc) a_january$new_var<-a_january$var1+a_january$var2
how do this?. how can put in loop , make happen? please let me know
first step important: not create variable each data.frame. instead, put them list of data.frames:
data <- list(a_january, a_february, a_december)
this might cumbersome type, if have hundreds of data.frames. if can tell how came create these data.frames might fix problem @ root.
once have list, easy modify of them:
data <- lapply(data, transform, new_var = var1 + var2)
Comments
Post a Comment