我试图在三列上合并两个数据帧,其中两列是精确的,一个的方差为+/- 5%。我想合并2个因素+ 1个数字。
这是我到目前为止使用的代码:
`matched <- merge(x = plans, y = sales, by = c("Subdivision","Builder","SquareFootage"), all.y = TRUE)`
我试图在这些变量上与JRip匹配。我想要的是将计划中的plan_name字段与销售数据框中的各个记录相匹配,细分和构建器上的完全匹配,以及square_footage上的匹配可能在10%之内。
以下是计划数据框的示例:
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
| Subdivision | Builder | Plan_name | Plan_label | SquareFootage |
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
| Barton Woods | Anglia Homes | 60-Bristol | Anglia Homes|60-Bristol | 2821 |
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
| Imperial Oaks/Meadows | Ashton Woods | Tyler | Ashton Woods|Tyler | 2701 |
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
| Harper's Preserve | Brighton Homes | 65-Stewart Alt. | Brighton Homes|65-Stewart Alt. | 2811 |
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
| Harmony | CastleRock Builders | 65-Santa Rosa | CastleRock Builders|65-Santa Rosa | 3304 |
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
| Stewart's Forest | Century Communities | 80-Marsala | Century Communities|80-Marsala | 3741 |
+-----------------------+---------------------+-----------------+-----------------------------------+---------------+
这是销售表的一个示例:
+-----------------------+--------------------------+---------------+---------------+
| Subdivision | Builder | SquareFootage | Parcel# |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Ashton Woods Homes | 2570 | 0334-00-00117 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Ashton Woods Homes | 3355 | 7167-02-05200 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Ashton Woods Homes | 3611 | 7167-02-03100 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Ashton Woods Homes | 2652 | 7167-02-00900 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2570 | 0334-00-00117 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2975 | 7167-00-02600 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2755 | 7167-00-02700 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2205 | 7167-00-03800 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2570 | 0334-00-00117 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2960 | 7167-00-02900 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2973 | 7167-00-03900 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2707 | 0334-00-00117 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2707 | 0334-00-00117 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2570 | 0334-00-00117 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2646 | 7167-00-01300 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2061 | 7167-00-00500 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2672 | 7167-00-03700 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2498 | 7167-00-00900 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2227 | 7167-00-02300 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2578 | 7167-00-02000 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2455 | 7167-00-03000 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Beazer Homes | 2530 | 7167-00-02200 |
+-----------------------+--------------------------+---------------+---------------+
| Stewarts Forest | Century Communities, Inc | 3816 | 9024-08-02700 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | J Patrick Homes | 4364 | 7167-03-03000 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Plantation Homes | 2307 | 7167-00-04200 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Plantation Homes | 3505 | 7167-02-06100 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Plantation Homes | 2122 | 7167-00-00300 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Plantation Homes | 3417 | 7167-02-02800 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Plantation Homes | 1992 | 7167-00-02400 |
+-----------------------+--------------------------+---------------+---------------+
| Imperial Oaks/Meadows | Plantation Homes | 2241 | 7167-00-03500 |
+-----------------------+--------------------------+---------------+---------------+