2017-05-21 20 views
0

我有2個陣列中R,ř粘貼2串與它之間等號: 「stringA」= 「stringB」

一個是

derive = c("excellent","bon","bad"); 

另一個是

couleurs = c("lightgreen","green","red"); 

我想要得到以下結果:

result = c("excellent"="lightgreen","bon"="green","bad"="red"); 

使用粘貼功能,我總是得到「」之間的全部結果,而「=」必須超出「」。

我嘗試過使用sep ='「」',但它創建了一個帶有轉義字符串的字符串「」。

有什麼想法?

感謝

+1

'名(COULEURS)< - derive'給出了對象'couleures'爲您定義'結果相同的結果= ...' – jogo

回答

0

使用names此:

derive  <- c("excellent","bon","bad") 
couleurs  <- c("lightgreen","green","red") 
result  <- couleurs 
names(result) <- derive 
+0

事實上,這給出了相同的結果,結果看起來不像我期望的那樣,但它以相同的方式被R解釋。這就是關鍵。 – jakzr