当有几名新来港定居人士在整个数据中分布时,我如何发现和计算指标变化的百分比?
让我们假设这是我的数据框架:
a b c d e
07 10 NA NA 8 7
06 8 NA 5 NA 8
05 11 NA 7 6 7
04 5 NA 6 5 9
03 NA NA NA NA NA
02 NA NA NA 3 12
01 NA NA 10 NA 15
Knowing that each row represents data from a certain year, I want to find the percentage of difference between the lowest row (earliest row) that contains a non-NA number and the uppermost row (latest row) that contains a non-NA number. The result should look like this:
a b c d e
1 NA -1 1.66 -0.53
The code should be easily replicated since I have hundreds of rows to analyse (eg: it shouldn t involve manually adding each column or row name). Any help will be greatly appreciated!