数据是一个平面标准化表:
|ID | Product selected | Product Code 1 | Product Code 2 | Product Code 3 | Cost of Product 1 | Cost of Product 2 | Cost of Product 3 | Rate of Product 1 | Rate of Product 2 | Rate of Product 3 |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|1 | ABCDEDFHIJKL | AAABBBCCCDDD | ABCDEDFHIJKL | DDDCCCBBBAAA | 995 | 495 | 0 | 4.4 | 6.3 | 7.8 |
|2 | DDDCCCBBBAAA | AAABBBCCCDDD | ABCDEDFHIJKL | DDDCCCBBBAAA | 995 | 495 | 0 | 4.4 | 6.3 | 7.8 |
什么:
使用所选产品 (ABCDEDFHIJKL),查看各行以找到具有与所选产品相关的数据的列的相应位置。
期望的输出:
| Product selected | Cost of Product | Rate of Product |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| ABCDEDFHIJKL | 495 | 6.3 |
| DDDCCCBBBAAA | 0 | 7.8 |
在 R 中做到这一点是直截了当的,我敢肯定,对于比我更懂 SQL 的人来说,这很容易