Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to convert searchTwitter results (from library(twitteR)) into a data.frame?
    text
    copied!<p>I am working on saving twitter search results into a database (SQL Server) and am getting an error when I pull the search results from twitteR. </p> <p>If I execute:</p> <pre><code>library(twitteR) puppy &lt;- as.data.frame(searchTwitter("puppy", session=getCurlHandle(),num=100)) </code></pre> <p>I get an error of:</p> <pre><code>Error in as.data.frame.default(x[[i]], optional = TRUE) : cannot coerce class structure("status", package = "twitteR") into a data.frame </code></pre> <p>This is important because in order to use RODBC to add this to a table using sqlSave it needs to be a data.frame. At least that's the error message I got:</p> <pre><code>Error in sqlSave(localSQLServer, puppy, tablename = "puppy_staging", : should be a data frame </code></pre> <p>So does anyone have any suggestions on how to coerce the list to a data.frame or how I can load the list through RODBC?</p> <p>My final goal is to have a table that mirrors the structure of values returned by searchTwitter. Here is an example of what I am trying to retrieve and load:</p> <pre><code>library(twitteR) puppy &lt;- searchTwitter("puppy", session=getCurlHandle(),num=2) str(puppy) List of 2 $ :Formal class 'status' [package "twitteR"] with 10 slots .. ..@ text : chr "beautifull and kc reg Beagle Mix for rehomes: This little puppy is looking for a new loving family wh... http://bit.ly/9stN7V "| __truncated__ .. ..@ favorited : logi FALSE .. ..@ replyToSN : chr(0) .. ..@ created : chr "Wed, 16 Jun 2010 19:04:03 +0000" .. ..@ truncated : logi FALSE .. ..@ replyToSID : num(0) .. ..@ id : num 1.63e+10 .. ..@ replyToUID : num(0) .. ..@ statusSource: chr "&amp;lt;a href=&amp;quot;http://twitterfeed.com&amp;quot; rel=&amp;quot;nofollow&amp;quot;&amp;gt;twitterfeed&amp;lt;/a&amp;gt;" .. ..@ screenName : chr "puppy_ads" $ :Formal class 'status' [package "twitteR"] with 10 slots .. ..@ text : chr "the cutest puppy followed me on my walk, my grandma won't let me keep it. taking it to the pound sadface" .. ..@ favorited : logi FALSE .. ..@ replyToSN : chr(0) .. ..@ created : chr "Wed, 16 Jun 2010 19:04:01 +0000" .. ..@ truncated : logi FALSE .. ..@ replyToSID : num(0) .. ..@ id : num 1.63e+10 .. ..@ replyToUID : num(0) .. ..@ statusSource: chr "&amp;lt;a href=&amp;quot;http://blackberry.com/twitter&amp;quot; rel=&amp;quot;nofollow&amp;quot;&amp;gt;Twitter for BlackBerry®&amp;lt;/a&amp;gt;" .. ..@ screenName : chr "iamsweaters" </code></pre> <p>So I think the data.frame of puppy should have column names like:</p> <pre><code>- text - favorited - replytoSN - created - truncated - replytoSID - id - replytoUID - statusSource - screenName </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload