[This article was first published on Pass the ROC, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I wrote an R script that pulled data from an RSS feed. The RSS feed updated frequently, so I wanted to be able to schedule the script to run automatically. After some tinkering, I got it to work by implementing the steps below. Note that these steps assume you do not want to save your workspace – that you are saving the objects you need explicitly within the script. Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Step 3: The Run Shell Script Action |
- Test your R script in regular ole’ R to make sure it runs without error.
- Add a quit(save=”no”) command at the end of your script.
- Open Automator (Applications -> Automator)
- Select Application from the Template Selection menu
- Select the Run Shell Script Action, double click or drag it over
- Type: Rscript –no-save –no-restore /Users…./YourScript.R
- The last argument should be the path of the script file you want to run
- The 2nd and 3rd arguments tell R not to save the workspace when it’s done and not to restore previously saved objects on startup, respectively
- To see a full list of arguments you can pass to Rscript, just open Terminal and type Rscript
To leave a comment for the author, please follow the link and comment on their blog: Pass the ROC.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.