For my master thesis I am analysing a food security model and the next element i need to obtain is the number of crisis transitions that have taken place in the researched period. A crisis transition is when the food security IPC values go from either 1 or 2 to 3,4 or 5 during the standard forecasting period(which initially was 3 months and later on 4 months, but that aside). So I would like to count the times that an area went from 1 or 2 to 3,4 or 5. I have a long dataframe that has a column with the period, the area(Livelihood zone) and the IPC value. I put the link to two csv files for you guys to download and check for yourselves.
What do you guys think is the best way to obtain this count per type of area? Let me know if you need additional information. I hope you guys can help, that would mean a lot!
Dput output of the first 48 rows, which means two periods and two times all the areas:
structure(list(`Livelihood zone` = c("Central Highlands, High Potential Zone",
"Marsabit Marginal Mixed Farming Zone", "Northwestern Agropastoral Zone",
"Southeastern Marginal Mixed Farming Zone", "Turkwell Riverine Zone",
"Western High Potential Zone", "Tana Riverine Zone", "Southeastern Medium Potential, Mixed Farming Zone",
"Northern Pastoral Zone", "Western Medium Potential Zone", "Western Lakeshore Marginal Mixed Farming Zone",
"Southern Pastoral Zone", "Northeastern Pastoral Zone", "Mandera Riverine Zone",
"Eastern Pastoral Zone", "Northeastern Agropastoral Zone", "Lake Turkana Fishing",
"Lake Victoria Fishing Zone", "Western Agropastoral Zone", "Coastal Medium Potential Farming Zone",
"Coastal Marginal Agricultural Mixed Farming Zone", "Southeastern Pastoral Zone",
"Northwestern Pastoral Zone", "Southern Agropastoral Zone", "Central Highlands, High Potential Zone",
"Marsabit Marginal Mixed Farming Zone", "Northwestern Agropastoral Zone",
"Southeastern Marginal Mixed Farming Zone", "Turkwell Riverine Zone",
"Western High Potential Zone", "Tana Riverine Zone", "Southeastern Medium Potential, Mixed Farming Zone",
"Northern Pastoral Zone", "Western Medium Potential Zone", "Western Lakeshore Marginal Mixed Farming Zone",
"Southern Pastoral Zone", "Northeastern Pastoral Zone", "Mandera Riverine Zone",
"Eastern Pastoral Zone", "Northeastern Agropastoral Zone", "Lake Turkana Fishing",
"Lake Victoria Fishing Zone", "Western Agropastoral Zone", "Coastal Medium Potential Farming Zone",
"Coastal Marginal Agricultural Mixed Farming Zone", "Southeastern Pastoral Zone",
"Northwestern Pastoral Zone", "Southern Agropastoral Zone"),
`Period of measurement Kenya` = c("2011-01", "2011-01", "2011-01",
"2011-01", "2011-01", "2011-01", "2011-01", "2011-01", "2011-01",
"2011-01", "2011-01", "2011-01", "2011-01", "2011-01", "2011-01",
"2011-01", "2011-01", "2011-01", "2011-01", "2011-01", "2011-01",
"2011-01", "2011-01", "2011-01", "2011-04", "2011-04", "2011-04",
"2011-04", "2011-04", "2011-04", "2011-04", "2011-04", "2011-04",
"2011-04", "2011-04", "2011-04", "2011-04", "2011-04", "2011-04",
"2011-04", "2011-04", "2011-04", "2011-04", "2011-04", "2011-04",
"2011-04", "2011-04", "2011-04"), `IPC class` = c(1, 3, 2,
2, 2, 1, 2, 2, 3, 1, 1, 2, 3, 3, 2, 3, 2, 1, 2, 2, 2, 2,
2, 2, 1, 3, 2, 2, 2, 1, 2, 2, 3, 1, 1, 2, 3, 3, 2, 3, 2,
1, 2, 2, 2, 2, 2, 2)), row.names = c(NA, 48L), class = "data.frame")
For the outcome I would like to have a dataframe which has a count of the crisis transitions per livelihood zone. Thanks in advance!