Changing series values conditionally
So, changing series values is often more complicated than the previous recipe suggests. We often need to set series values based on the values of one or more other series for that row of data. This is complicated further when we need to set series values based on values from other rows; say, a previous value for an individual, or the mean for a subset. We will deal with these complications in this and the next recipe.
Getting ready
We will work with land temperature data and the National Longitudinal Survey data in this recipe.
Data note
The land temperature dataset contains the average temperature readings (in Celsius) in 2019 from over 12,000 stations across the world, though the majority of the stations are in the United States. The raw data was retrieved from the Global Historical Climatology Network integrated database. It has been made available for public use by the United States National Oceanic and Atmospheric Administration...