title: Aggregate error 'invalid type (closure) for variable 'paste'
body: <p>For <a href="https://stackoverflow.com/questions/20966480/whats-the-r-statement-responding-to-sqls-in-statement">this question</a> @SimonO101 suggested <code>aggregate</code> solution in comments, as below:</p>
  
  <pre><code>#dataframe
  df &lt;- data.frame(id=c(101,102,102,103,104,104,104),
                   calmonth=c('01','01','01','01','01','01','02'),
                   product=c('apple','apple','htc','htc','apple','htc','nokia'),
                   bb=sample(1:20,7))
  
  #aggregate - SimonO101's solution:
  aggregate(product~id+calmonth, data=df, FUN=paste, collapse=" &amp; ")
  
  #Error
  </code></pre>
  
  <blockquote>
    <p>Error in model.frame.default(formula = ~product + paste, data = list(id = c(101,  : 
    invalid type (closure) for variable 'paste'</p>
  </blockquote>
  
  <p>Can't figure out the cause of this error?</p>
  
  <p><strong>Version:</strong></p>
  
  <pre><code>Windows 7 Enterprise SP1, 64bit OS, "R version 3.0.1 (2013-05-16)", RStudio
  </code></pre>
  
  <p><strong>Update:</strong> Opened new RStudio session, no error, still would like to find out the cause.</p>
  
  <p><strong>Update:</strong> dput:</p>
  
  <pre><code>dput(df123)
  structure(list(id = c(101, 102, 102, 103, 104, 104, 104), calmonth = structure(c(1L, 
  1L, 1L, 1L, 1L, 1L, 2L), .Label = c("01", "02"), class = "factor"), 
      product = structure(c(1L, 1L, 2L, 2L, 1L, 2L, 3L), .Label = c("apple", 
      "htc", "nokia"), class = "factor"), bb = c(19L, 17L, 5L, 
      15L, 16L, 4L, 9L)), .Names = c("id", "calmonth", "product", 
  "bb"), row.names = c(NA, -7L), class = "data.frame")
  </code></pre>
  
  <p><strong>Update:</strong> conflicts</p>
  
  <pre><code>conflicts()
   [1] "dbCallProc"        "dbClearResult"     "dbColumnInfo"      "dbCommit"         
   [5] "dbConnect"         "dbDataType"        "dbDisconnect"      "dbExistsTable"    
   [9] "dbGetException"    "dbGetInfo"         "dbGetQuery"        "dbGetRowCount"    
  [13] "dbGetRowsAffected" "dbGetStatement"    "dbHasCompleted"    "dbListConnections"
  [17] "dbListFields"      "dbListResults"     "dbListTables"      "dbReadTable"      
  [21] "dbRemoveTable"     "dbRollback"        "dbSendQuery"       "dbUnloadDriver"   
  [25] "dbWriteTable"      "fetch"             "isSQLKeyword"      "make.db.names"    
  [29] "SQLKeywords"       "summary"           "fillin"            "recode"           
  [33] "untangle.specials" "%nin%"             "codebook"          "coerce"           
  [37] "initialize"        "recode"            "rename"            "show"             
  [41] "summary"           "dotplot"           "contr.sum"         "contr.treatment"  
  [45] "contrasts"         "contrasts&lt;-"       "Arith"             "coerce"           
  [49] "Compare"           "initialize"        "Math"              "Math2"            
  [53] "show"              "Summary"           "%in%"              "as.array"         
  [57] "as.factor"         "as.ordered"        "as.vector"         "body&lt;-"           
  [61] "format"            "format.pval"       "kronecker"         "labels"           
  [65] "print"             "round.POSIXt"      "row.names"         "sample"           
  [69] "subset"            "summary"           "trunc.POSIXt"      "unique"           
  [73] "units"             "within"
  </code></pre>