Automation through R

Dears,
Is there a solution that R can held automatic jobs in a certain times already set by me. For example once a file found in a folder, automatically import this file and do some jobs , then update a database with cleaned data. could it be done. Frankly i'm a new R user and want to apply most of my work with it :slight_smile: Appreciate your kind support and your encouraging spirit.
Regards

R is a language that you could use for very different purpose. You can write script and make them executable. After that, you can do what is possible on your OS. So yes you can do a script that watch a folder every x times and do something when condition is met.

For scheduling tasks in R you can find these two :package: useful depending what is your OS.
https://cran.r-project.org/web/packages/cronR/README.html
https://cran.r-project.org/web/packages/taskscheduleR/index.html

Hope this few hints will help you start.

1 Like

You can install packages like taskscheduleR to schedule your R script (which checks for a file, does some task and updates the database). Personally, I use Cron to do my automation, the idea is same except with Cron job you can automate various scripts written in different languages(including R).

2 Likes

I would not depend on any R packages for such a task - its probably better and more OS generic to use something like Jenkins to schedule your workflows and such. Especially as it integrates nicely with your SCM (e.g. Github). Im sure there is a plugin that triggers jobs on file changes as well but probably there are better solutions to setup everything without relying on extra plugins. E.g. just put all the files in your git repo and any change there will trigger a jenkins job executing your R workflow.

1 Like

You are depending on packages all the way - R is a language of packages. You would not get very far relying on the base R to do all your work, refusing all the help dplyr, ggplot or DBI and the related database lot can offer.

cronR (one happy customer running a Linux server here) is a minor convenience compared to these...

1 Like

Appreciate your kind support, thanks a million :slightly_smiling_face::pray:

1 Like

Thanks a million appreciate your support :pray:

:pray::pray::pray: thanks a million