library("jrAutomate")
library("shiny")
library("flexdashboard")

Exercise 1

Exercise 2

Exercise 3

Unfortunately, to run scheduler tasks it depends on

This means it's hard to get an exercise that will suit everyone. To get the general idea across I've created a simple function called scheduler().

When we run the same script multiple times, there are two possibilities:

Exercise 3

Create a standard Rmd file (don't worry about params). In the body of the document include

x = rnorm(10)
plot(x)
pdf("fileA.pdf")
plot(x)
dev.off()

We want to change fileA.pdf to be unique. The easiest way is to use current time. In R we have

Sys.Date()
Sys.time()

In this exercise we'll use Sys.time(), but you may find Sys.Date() more suitable in general. We need to convert the time to a file name. First convert it to a character

fname = as.character(Sys.time())

Then add on a pdf file extension using the paste0() function

fname = paste0(as.character(Sys.time()), ".pdf")

Now change fileA.pdf to use fname. Run your script and ensure that it works.

Exercise 4

The scheduler() function is simple. It has three arguments:

library(jrAutomate)
## time between is in seconds
scheduler(script_name = "my_script.Rmd", repeats = 5, time_between = 5)

Using the scheduler() function, run your Rmd file 5 times with a 3 second interval.

Handy functions for file manipulation

Function name | Description --------------|------------ dir.create() | Creates a new directory dir.exists() | Checks a directory exists file.create() | Creates a new file file.exists() | Checks a file exists file.remove() | Removes a file file.info() | Size, creation date, etc.



jr-packages/jrAutomate documentation built on Dec. 14, 2019, 6:35 p.m.