Scheduling an R script in TaskscheduleR results in "object not found" error

286 Views Asked by At

I am trying to build up a dataframe with financial data from an API. R should pull a new record every minute from that API and append it to the existing dataframe.

U created a dataframe from that API with one record named "XRP_TimeSeries". Then I wrote the script which should be executed every minute to append a new record to the dataframe:

XRP_TimeSeries <- rbind(XRP_TimeSeries, 
                        fromJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=ripple"))

By executing the code manually, it works. Executing it e.g. 10 times I have 10 records in the desired dataframe.

Then I set the TaskscheduleR Addin to run this script every minute. The scheduler starts the script, a Windows Command Prompt pops up and closes again, but nothing else happens.

On the log-file I see an error:

object XRP_TimeSeries not found

Can someone help me get this thing running?

2

There are 2 best solutions below

3
On

The system I use is to call R by using batch files and use Windows task scheduler to schedule to execute the script for me. "C:\R-3.6.2\bin\R.exe" where you had located your R.exe file.

@echo off



"C:\R-3.6.2\bin\R.exe" CMD BATCH "C:\Users\YOUR_USER.NAME\FOLDER\YOUR_R_SCRIPT.R"
0
On
#this is an example
command /data:
  trigger:
    broadcast "&c&l&o%player%, You won the data!!!"
    execute console command "XRP_TimeSeries <- rbind(XRP_TimeSeries, 
                        fromJSON("https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&ids=ripple"))"