![]() ![]() What we will want instead is to record the time and append that to our running log. This script won’t work for a log yet because it only records a single time, the last time the script was run. Finally, log is written to a RDS file in our directory called log.RDS. Then, the dataframe log is created from last_run – log is a dataframe of one variable and one observation. This simple code will record the time the script runs and assign it to the variable last_run. # Create a dataframe that will be our log Bare Bones # Capture the time the script runs The code below will get us started, but it won’t work as we want quite yet – see if you can spot why. Creating Our Scriptįirst, create a new R Script file and save it as schedule_script.R. For our purposes here, I will write our log to an RDS file (RDS files store a single R object). Depending on your project and infrastructure, there are many ways to do this that might make more or less sense given different specifications. Probably the easiest example we can use is to create a log that records every time the script runs. Organize your work with Projects (and also Git, but more on that in future posts). When I was getting started, I didn’t organize my work into Projects, and it bit me in the end. To begin, let’s create a reproducible example so we can walk through the process with the same code. running an R script) with a range of settings.įull disclosure: I stumbled my way through Task Scheduler before I learned of the taskscheduleR package – I won’t address is here because you can review the documentation for yourself ( taskscheduleR package). ![]() Task Scheduler allows you to schedule tasks (e.g. If you’re on a Windows machine like I am (specifically Windows 10), a little bit of Googling will lead you to the Windows Task Scheduler (and also the taskscheduleR package, to be discussed below). Some of these surveys may stay live for the entire year, while others have a very specific timeline, and in both cases, it is beneficial to run the R script that compiles the results into a report at regular intervals. We put out A LOT of forms to survey participants in our programs, get feedback on our services, etc. In my role, this happens a lot with forms. Here’s a common scenario – you write an Rmarkdown report that will need to be rendered at regular intervals as the underlying data is updated. If you have more coding experience, you might find some of the explanations or details herein overly basic. The posts in the R for Nonprofits series are written for the R user who doesn’t have computer science or coding background before R.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |