0

I have 2 DataFrames(DF) and i want to write values from one DF to the second DF if 2 specific Values are matching. For better understanding here my example:

https://www.dropbox.com/s/gkuwn2k214h4syk/example.gif

what i exactly want to do is:

if "item_id" (DF complete) is matching "item_id" (DF Prices) then write the "item_price" (DF Prices) in "price" (DF complete)

my little attempt is :

for (i in 1: length(Prices$item_id){
   for (j in 1: length(complete$text_id) ){

     if ( complete$item_id[j]==Prices$item_id[i])
       Prices$item_Price = complete$price  

     j = j+ 1}
   i = i + 1 }`


Error in `$<-.data.frame`(`*tmp*`, "pr_listPrice", value = c(0, 0, 0,  : 
  replacement has 10000 rows, data has 591
>   i = i + 1 }
Error: unexpected '}' in "  i = i + 1 }"

-> the "pr_listPrice" in the Error is "item_Price" (DF Prices) in the example

I think this should be not too hard, but I am fighting with the loop since a while :-)

Simon O'Hanlon
  • 58,647
  • 14
  • 142
  • 184
Laudl007
  • 51
  • 4

0 Answers0