I have this df.
Date <- c("2020-10-01", "2020-10-02", "2020-10-03", "2020-10-04",
"2020-10-01", "2020-10-02", "2020-10-03", "2020-10-04",
"2020-10-01", "2020-10-02", "2020-10-03", "2020-10-04")
Country <- c("USA", "USA", "USA", "USA",
"Mexico", "Mexico", "Mexico", "Mexico",
"Japan", "Japan", "Japan","Japan")
Value_A <- 1:12
Value_B <- 10:21
Date Country Value_A Value_B
<date> <chr> <int> <int>
1 2020-10-01 USA 1 10
2 2020-10-02 USA 2 11
3 2020-10-03 USA 3 12
4 2020-10-04 USA 4 13
5 2020-10-01 Mexico 5 14
6 2020-10-02 Mexico 6 15
7 2020-10-03 Mexico 7 16
8 2020-10-04 Mexico 8 17
9 2020-10-01 Japan 9 18
10 2020-10-02 Japan 10 19
11 2020-10-03 Japan 11 20
12 2020-10-04 Japan 12 21
What I want is break this df into n parts, each part being a country. Something like:
list <- list(df[1:4,], df[5:8,], df[9:12,])
ps: for my purposes, the dataframes should stay "long".
ps2: I simplified the df, I have like 50 countries.
I appreciate it if someone can help :)