I would like to create a loop over 3 data frames and creates subsets of each and assign to these new subsets a new name. How can I loop over these three data frames while maintaining the names?
For example, I have 3 data frames: apples, berries, and grapes. When making a loop, is there a way to assign the new subset data frames similar names to their respective original data frame?
Written out without a loop, this is what the code would look like.
apples <- data.frame(type = c("red", "golden", "green"), number = c(1, 2, 3))
berries <- data.frame(type = c("blueberry", "raspberry", "mulberry"), number = c(1, 2, 3))
grapes <- data.frame(type = c("red", "green", "sour"), number = c(1, 2, 3))
apples_large <- subset(apples, number > 2)
apples_small <- subset(apples, number < 2)
berries_large <- subset(berries, number > 2)
berries_small <- subset(berries, number < 2)
grapes_large <- subset(grapes, number > 2)
grapes_small <- subset(grapes, number < 2)