1

I'm to trying to run an r-script from the command line. The script prompts a "1"/"2" input. How can I automate the answer to be 2 via a batch file?

In particular, I have the file "run.R" with the following script within:

require(twitteR)
oauth <- setup_twitter_oauth(cred$consumerKey, cred$consumerSecret, cred$accessToken, cred$accessTokenSecret)
# more code...

When running the above script from the command line - Rscript run.R - the function setup_twitter_oauth prompts the following:

[1] "Using direct authentication"
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No

Selection: 

How can I automate the answer to be 2 when running the script from the command line or through a batch file?

Stan
  • 1,042
  • 2
  • 13
  • 29

1 Answers1

1

I think that it can help you!

You should include options(httr_oauth_cache=F) in your run.R file.

I hope this help! (Idea took from @NicE)

adlop
  • 41
  • 6
  • Please do not post links to [duplicate answers](//meta.stackexchange.com/a/211726/206345). Instead, consider other actions that could help future users find the answer they need, as described in the linked post. – Mogsdad May 05 '16 at 15:20