Hi!
Thanks for your reaction. In the meantime, I solved my issue while making a reprex.
My solution:
df_obs <- data.frame(stringsAsFactors = FALSE,
Fruit = c("Apple", "Apple", "Pear", "Pear", "Banana", "Banana"),
Date = c("22/02/2022", "23/02/2022", "22/02/2022", "23/02/2022","22/02/2022", "23/02/2022"),
Sold = c(5,3,6,2,8,6)
)
all_fruits <- list("Apple", "Pear", "Banana")
for (i in all_fruits) {
df_i <- subset(df_obs, Fruit == i)
print(df_i)
}```