x <- data.frame("occ_id" = c(1010, 1010, 1010, 1010, 1010, 1010, 1010,1234,1234,1234,1234, 4321, 4321,4321,4321,4321),
"Ind_id" = c(52418,52417,28339,27138,31224,33103,1112,27138,31224,1112,52418,33103,31224,1112,52417,26301),
"Change_occ_2000_2021" = c(1, -5 , 8 ,9 , - 11 ,15 ,16 ,-50,10,30,-5,20,10,50,30,-50))
I'm trying to see the change of occupations in the industry over time, so I have the occupations IDs like an engineer, teacher, and lawyer, and several IDs that correspond to the sector like construction, education, mineral extraction, fishing... I would like to extract, from each occupation -and the largest and smallest change. A sample of the data follows. In this example, I would like to extract from occupation 1010 that the largest positive change was in sector 1112 with an increase of 50 workers, and the largest negative change was in sector 31224 with a decrease of -50 workers. Could you guys help me?