title: twitteR lookupUsers for loop
body: <p>I'm relatively new to both R and twitteR and am attempting to write some code that will allow me to export a data frame showing multiple Twitter User Names, the number of friends for each, the number of followers for each, the number of times they are listed in public lists, and the number of time they have been mentioned, hopefully making it look like below:</p>
  
  <p><strong>User</strong> | <strong>Date</strong> | <strong>Friends</strong> | <strong>Followers</strong> | <strong>Listed</strong> | <strong>Mentions</strong> | <strong>StatusCount</strong></p>
  
  <p>The closest reference I could find on SO is <a href="https://stackoverflow.com/questions/19320706/using-twitter-package-how-to-solve-twinterfaceobjdoapicallcmd-params-method">this question, which is on "Hold"</a>, and when I try running the code listed, it gives the following error:</p>
  
  <pre><code>"Error in fix.by(by.x, x) : 
    'by' must specify one or more columns as numbers, names or logical"
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>library(RCurl)
  library(bitops)
  library(digest)
  library(ROAuth)
  library(rjson)
  library(twitteR)
  options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
  
  load("twitteR_credentials")
  registerTwitterOAuth(twitCred)
  
  clients &lt;- lookupUsers(c('Name','Name1','Name2'), cainfo = "cacert.pem")
  
  for(i in 1:length(clients)) {
     start &lt;- getUser(clients[i])
     friends.object &lt;- start$friendsCount
     followers.object &lt;- start$followersCount
     status.object &lt;- start$statusesCount
     listed.object &lt;- start$listedCount
     mentions.object &lt;- start$mentions
     data &lt;- merge(data.frame(User=start$id, Friends=friends.object), 
                   data.frame(User=start$id, Followers=followers.object), 
                   data.frame(User=start$id, Statuses=status.object), 
                   data.frame(User=start$id, Listed=listed.object)
                   data.frame(User=start$id, Mentions=mentions.object), all=T)
     filename &lt;- paste(clients[i],"Twiter Data.csv", sep=' ')
     setwd("filepath")
     write.csv(data, file=filename)
     remove(data)
  }
  </code></pre>
  
  <p>Any help would be appreciated.</p>