I am new here. I have a dataset of different towns with monthly temperatures over a 10-year period (i.e. 120 months). The dataset has just over 16,000 towns. I want a new variable which gives me the number of times each town recorded temperature exceeding a given threshold, say 15 degrees. Is there a simple was to do this without reshaping the data? Here is the sample data for the first 5 towns over the first 5 months
Code:
+------------------------------------------------------+ | town_id month1 month2 month3 month4 month5 | |------------------------------------------------------| 1. | 1 17 10 28 4 6 | 2. | 2 14 29 15 20 16 | 3. | 3 26 7 4 5 7 | 4. | 4 25 6 29 13 10 | 5. | 5 6 17 7 5 24 | +------------------------------------------------------+
0 Response to How do I create a new variable which counts number of variables that satisfy a given condition?
Post a Comment