0

I run the following script using an installation of RStudio on a Linux-Server.

require(twitteR)
require(plyr)

setup_twitter_oauth(consumer_key='xxx', consumer_secret='xxx', 
                    access_token='xxx', access_secret='xxx')

searchResults <- searchTwitter("#vds", n=15000, since = as.character(Sys.Date()-1), until = as.character(Sys.Date()))
head(searchResults)

tweetsDf = ldply(searchResults, function(t) t$toDataFrame())
write.csv(tweetsDf, file = paste("tweets_vds_", Sys.Date(), ".csv", sep = ""))

The script works fine, when I run it from the user-interface.

However, when I automatically run it via the terminal using crontab, I get the following error-message:

[1] "Using direct authentication"

Error in twInterfaceObj$getMaxResults : 
  could not find function "loadMethod"
Calls: searchTwitter -> doRppAPICall -> $
Execution halted

Why?

feder80
  • 1,195
  • 3
  • 13
  • 34
  • 1
    try adding `library(methods)` as well – NicE Feb 20 '15 at 16:54
  • Great, that seems to work. Can you explain why? – feder80 Feb 20 '15 at 17:23
  • he is using a `class` relying on the methods package. When you run R in interactive mode this library is loaded by default, not when you use RScript. See [this](http://r-pkgs.had.co.nz/namespace.html) for more info, it would need to be in the Depends not in the Imports of the package. You might want to write to the author to let him know of this bug. – NicE Feb 22 '15 at 01:11
  • OK. I geht it. Thank You. My questions are answered! – feder80 Feb 22 '15 at 12:12

0 Answers0