我有兩個數據集。一個只有一個註冊號碼(A),另一個有一個註冊號碼列表和註冊號碼旁邊的型號(B)。操縱兩個具有公共字段的數據幀
一個
一個
ircraft.reg.num Action Description Service.Type C/O Order.Type Created.on Actual.release.date
5Y-BX Re-Assembling of Aircraft C/O ZS08 40512 40532
5Y-BX Re-Assembling of Aircraft C/O ZS08 40512 40532
5Y-BX Re-Assembling of Aircraft C/O ZS08 40512 40532
5Y-BX Dual Control Collective Lever ZS08 40497 40550
5Y-BX Dual Control Collective Lever ZS08 40497 40550
5Y-BX Perform SB 63-10 MGB plug ZS08 40548 40550
5Y-BX Perform SB 63-10 MGB plug ZS08 40548 40550
5Y-BX Defect Pitot static cover burnt ZS08 40497 40550
5Y-CD Airworthiness Inspection & Test ZS08 40711 40711
5Y-CD Airworthiness Inspection & Test ZS08 40711 40711
5Y-CD Airworthiness Inspection & Test ZS08 40711 40711
乙
Reg. Aircraft.Model
5O-MV AS 355
5O-Unknown SA 318
5O-Unknown SA 318
5T-Unlnown SA 318
5T-BF BO 105
5T-BW AS 350
5T-BX AS 350
5T-BY AS 350
5T-CA BK 117
5T-CC AS 350
5T-CD AS 350
5T-DK AS 350
5T-DS AS 350
5T-DS AS 350
我想知道,如果在一個登記號等於B中的登記號,是什麼型號的類型?
我目前使用的:
if(A$Aircraft.reg.num -> B$Reg.){
model <- reg.no$Aircraft.Model
}
但它不工作,因爲我data.frames甚至不長。
有關如何在不使用「if」函數的情況下獲得結果的任何建議?
感謝, 卡門
你可能需要'合併'而不是if語句 – Cath
這是一個** [可重現的例子](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible -例)**。使用'dput()'轉儲數據幀,以便我們實際編寫代碼。 – smci