The interesting challenge there was to schedule this to run daily, saving the tweets in a CSV file incrementally.
I found two ways online -- the familiar Windows Task Scheduler way and using taskscheduleR
I already use Windows Task Scheduler for a couple of Python scripts and familiar with the setup, so I decided to go along with it.
It is straightforward to use. I have broken the entire process into two steps:
Step 1: Create a Batch file to run the R script
Create an empty text file and save it as .bat file. Then get the executable path of your R installation. Mine is C:\Program Files\Microsoft\MRO-3.3.1\bin\R.exe
Also get the path of your R script.
Now set up the .bat file like I did mine below
@echo off
"C:\Program Files\Microsoft\MRO-3.3.1\bin\R.exe" CMD BATCH "C:\Users\Michael Olafusi\Documents\TwitterScrapper.R"
Step 2: Create the Scheduler Task
Launch the Task Scheduler (just search for it if you use Windows 10, 8 and 7).
In the Task Scheduler window, at the right pane, click on Create Task.
And follow my screenshot guide below.
And that is it!
And that's how I scheduled the R script to daily mine tweets about Buhari, Osinbajo, Biafra and what's trending in Nigeria.
I intend to do a trend sentimental analysis on them going into the Election days in 2019.
No comments:
Post a Comment