0

I am a really newbie of R and I have the following dataframe named (errore33):

        LVCSERIALNUMBER      ADGIS     SERIALNUMBER EXECOUNT ERRCOUNT PLCCOMMUNICATIONSTATUS
  36236  14CEC50610022451 ca0a1c0054e9 1.009143e+15       27        1                      0
  106219 14CEC50610022451 ca0a1c005848 1.009143e+15       25        2                      0
  106230 14CEC50610022451 ca0a1c0065b0 1.009143e+15       25        2                      0
  106355 14CEC50610022451 ca0a1c005a59 1.009143e+15       25        2                      0
  106423 14CEC50610022451 ca0a1c0064b3 1.009143e+15       25        2                      0

In addition I have another dataframe called tabellacompleta1

    LVC_ID             TAB_CE_ADGIS   STATUS ROW_NUM TAB_CE_COMMUNICATION_LINE T_RPT_HOP_TABLE_PRI_1 T_RPT_HOP_TABLE_PRI_2 T_RPT_HOP_TABLE_PRI_3
  1 "14CEC50610022451" "1.009163e+15" "RAG"  "  1"   "      11"                "172"                 "191"                 "  5"                
  2 "14CEC50610022451" "1.009151e+15" "RAG"  "  2"   "    1011"                "  0"                 "  0"                 "  0"                
  3 "14CEC50610022451" "1.009162e+15" "RAG"  "  3"   "    1011"                "  0"                 "  0"                 "  0"                
  4 "14CEC50610022451" "1.009162e+15" "RAG"  "  4"   "10001011"                "  3"                 "  0"                 "  0"                
  5 "14CEC50610022451" "1.009143e+15" "RAG"  "  5"   "10000011"                "172"                 "191"                 " 42"                

Now my problem is to add a column to errore33 with the numeric value of ROW_NUM column when the following condition happens errore33.SERIALNUMBER == tabellacompleta1.TAB_CE_ADGIS

Just to clarify, in case of the first serialnumber == the third tab_ce_adgis then i have to add in the first position of errore33 in the newcolumn the numeric value 3 (the numeric value of ROW_NUM)

A. F.
  • 13
  • 3
  • Welcome to SO. Please note that all examples you post need to be [reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Also expected output and code you have tried and failed are also a must. – Sotos Nov 10 '16 at 13:58
  • Try `merge(errore33, tabellacompleta1, by.x="LVCSERIALNUMBER", by.y="TAB_CE_ADGIS", all.x=TRUE)` – Pierre L Nov 10 '16 at 13:59
  • Be sure to convert `tabella` to a data.frame, it appears to be a matrix – Pierre L Nov 10 '16 at 14:11
  • Hello Pierre, I used the merge you suggested and it works, thanks – A. F. Nov 15 '16 at 08:48

0 Answers0