I have three list which has data.frame object but with very different order fore sure. I want to let them have same order either like list1, list2 or list 3. How can I reverse the order of data.frame object in different list has same pattern/order? Does anyone give me some possible idea for doing this sort of manipulation easily? Thanks a lot.
with variable in the list, we can use public data like airquality, iris, cars, CO2 for quick run in R;
data
list1 <- list(pass=list(Alpha.df1_yes, Beta.df1_yes, Gamma.df1_yes, Theta.df1_yes),
fail=list(Alpha.df1_no, Beta.df1_no, Gamma.df1_no, Theta.df1_no))
list2 <- list(pass=list(Beta.df2_yes, Alpha.df2_yes, Gamma.df2_yes, Theta.df2_yes),
fail=list(Beta.df2_no, Alpha.df2_no, Gamma.df2_no, Theta.df2_no))
list3 <- list(pass=list(Gamma.df3_yes, Alpha.df3_yes, Beta.df3_yes, Theta.df3_yes),
fail=list(Gamma.df3_no, Alpha.df3_no, Beta.df3_no, Theta.df3_no))
list4 <- list(pass=list( Theta.df4_yes, Alpha.df4_yes, Beta.df4_yes,Gamma.df4_yes),
fail=list(Theta.df4_no, Alpha.df4_no, Beta.df4_no,Gamma.df4_no ))
desired output (let's have same pattern with list1 does):
list1 <- list(pass=list(Alpha.df1_yes, Beta.df1_yes, Gamma.df1_yes, Theta.df1_yes),
fail=list(Alpha.df1_no, Beta.df1_no, Gamma.df1_no, Theta.df1_no))
list2_NeW <- list(pass=list(Alpha.df2_yes, Beta.df2_yes, Gamma.df2_yes, Theta.df2_yes),
fail=list(Alpha.df2_no, Beta.df2_no, Gamma.df2_no, Theta.df2_no))
list3_New <- list(pass=list(Alpha.df3_yes, Beta.df3_yes,Gamma.df3_yes, Theta.df3_yes),
fail=list(Alpha.df3_no, Beta.df3_no, Gamma.df3_no, Theta.df3_no))
list4_New <- list(pass=list(Alpha.df4_yes, Beta.df4_yes,Gamma.df4_yes, Theta.df4_yes),
fail=list(Alpha.df4_no, Beta.df4_no, Gamma.df4_no, Theta.df4_no))
because data are in the nested structure, it is bit of tricky to let them have same pattern in the new constructed list. Can anyone propose possible ideas?