Is there an easy way to simplify this code using a loop?
问题 Is there a way to simplify this code using a loop? set.seed(100) AL_INDEX <- sample(1:nrow(AL_DF), 0.7*nrow(AL_DF)) AL_TRAIN <- AL_DF[AL_INDEX,] AL_TEST <- AL_DF[-AL_INDEX,] AR_INDEX <- sample(1:nrow(AR_DF), 0.7*nrow(AR_DF)) AR_TRAIN <- AR_DF[AR_INDEX,] AR_TEST <- AR_DF[-AR_INDEX,] AZ_INDEX <- sample(1:nrow(AZ_DF), 0.7*nrow(AZ_DF)) AZ_TRAIN <- AZ_DF[AZ_INDEX,] AZ_TEST <- AZ_DF[-AZ_INDEX,] AL_DF, AR_DF & AZ_DF are data frames that have the same field structure, but different number of records.