【发布时间】:2016-02-29 22:55:09
【问题描述】:
在 R 中,我需要执行与 Excel 中的索引匹配类似的功能,它返回的值刚好大于查找值。
数据集 A
Country GNI2009
Ukraine 6604
Egypt 5937
Morocco 5307
Philippines 4707
Indonesia 4148
India 3677
Viet Nam 3180
Pakistan 2760
Nigeria 2699
数据集 B
GNI2004 s1 s2 s3 s4
6649 295 33 59 3
6021 260 30 50 3
5418 226 27 42 2
4846 193 23 35 2
4311 162 20 29 2
3813 134 16 23 1
3356 109 13 19 1
2976 89 10 15 1
2578 68 7 11 0
2248 51 5 8 0
2199 48 5 8 0
在每个国家/地区的 2009 年级别 GNI(数据集 A)我想找出哪个 GNI2004 刚好大于或等于 GNI2009,然后在该行返回相应的销售值(s1,s2...) (数据集 B)。我想对表 A 中 2009 年的每个 Country-gni 行重复此操作。
例如:Nigeria 在数据集 A 中带有 GNI2009 of 2698 将返回:
GNI2004 s1 s2 s3 s4
2976 89 10 15 1
在 Excel 中,我猜这类似于索引和匹配,其中匹配条件为 match(look up value, look uparray,-1)
【问题讨论】:
-
请查看How to Ask问题。
-
您好,我如何在引用示例时像其他人一样在表格中输入数字?谢谢
-
我猜它现在很好:)
标签: r excel indexing match lookup