title: Join on stored variables in a loop
body: <p>I need to anti join on variables that are implicitly stored and updated in a loop. Here is the code:</p>
  
  <pre><code>    #initialize vectors
  SourceColumn = NULL
  TargetColumn = NULL
  InSource_NotInTarget = NULL
  InTarget_NotInSource = NULL
  CountNASource = NULL
  CountNATarget = NULL
  Count_Source_Total_Rows = NULL
  Count_Target_Total_Rows = NULL
  Count_Source_Unique_Rows = NULL
  Count_Target_Unique_Rows = NULL
  SourceRowType = NULL
  TargetRowType = NULL
  
  for (i in names(nmMappingLOAD_CC_C_PROJECT_CONFIG)){
    a1Ind = paste(i)
    a2Ind = paste(nmMappingLOAD_CC_C_PROJECT_CONFIG[i])
  
  
    #DB data(Target)
    a1 = adhocTibl[a1Ind]
    #Excel data(Source)
    a2 = excelData[a2Ind]
  
    #Build col vectors
  
    #fails here
    Count_InTarget_NotInSource = append(InTarget_NotInSource, nrow(anti_join(a1, a2, by = c(names(a1) = names(a2)))))
    Count_InSource_NotInTarget = append(InSource_NotInTarget, nrow(anti_join(a2, a1, by = c("PROJECT_ID"="PROJECT_CONFIG_ID"))))
  
  
  }
  </code></pre>
  
  <p>It fails here <code>Count_InTarget_NotInSource = append(InTarget_NotInSource, nrow(anti_join(a1, a2, by = c(names(a1) = names(a2)))))</code></p>
  
  <p>With the error <code>Error: Error: unexpected '}' in "}"</code></p>
  
  <p>I can explicitly state the join columns like <code>by = c("PROJECT_CONFIG_ID"="PROJECT_ID"))))</code> and it will work, but for this case, I am looping through multiple columns in both tables and the column names are updated in the loop.</p>