bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
331 stars 72 forks source link

Streaming twitter in taskschedulaR... #47

Closed herrmannrobert closed 6 years ago

herrmannrobert commented 6 years ago

Streaming twitter (rtweet package) works fine for me when manually running the code - but not when scheduling the task using the RStudio-AddIn (stops immediately after it starts running). Any idea...?

Loading and saving the access token:

library("rtweet")
appname <- "herr[...]mann"
key <- "SzA[...]1o7u"
secret <- "4MtSJom[...]WjdgRUuz"
twitter_token <- create_token(app = appname, consumer_key = key, consumer_secret = secret)

saveRDS(twitter_token, "twitter_token.rds")

Then scheduling (or manually running) the task:

library("rtweet")
twitter_token <- readRDS("twitter_token.rds")
stream_tweets(q = "election", file_name = "...", timeout = 60)

Thanks for any hint...

jwijffels commented 6 years ago

Look at the log and use full paths to your read/write ops