How to run an R-script file within Kaggle - r

I have an R script file currently saved in my local computer. This is computationally intensive script which download data from Internet and save data in csv files in local disk.
I was thinking if I can run this script within Kaggle and save the data in csv files in Google drive. I also intend to run that script everyday at scheduled time.
Can you please guide me if this is a good idea to implement? How can I deploy this script in Kaggle and have it run based on scheduled time?
Your pointer will be highly appreciated.
s

Related

How to run an R file on schedule basis? Preferably on the cloud

How can I run an R script on an automatic schedule either locally, or better on the cloud? I have tried to create a batch file unsuccessfully. If I could schedule the file to run through MS Power Automate that would be perfect. Any ideas?

How to change working directory/read from local csv in an R script used as a data source in Power BI?

I am trying to use an R script as a data source for Power BI. I am a regular user of R but am new to Power BI. When all the datasets that are imported by the R script are from SQL databases I can import the resulting dataframes from the R script fine, however I have a script that uses a .csv file that Power BI's R session can't find which results in the error:
Error: 'times_of_day_grid.csv' does not exist in current working directory ('C:/Users/MyUserName/RScriptWrapper_ac2d4ec7-a4f6-4977-8713-10494f4b0c4f').
The .pbix file and the R script are both stored in the same folder as the csv
I have tried manually setting the wd by inserting into the script
setwd("C:/Users/MyUserName/Documents/R/Projects/This Project Folder")
But this just results in the message
"Connecting - Please wait while we establish a connection to R"
And later if I leave it running:
Unable to connect
We encountered an error while trying to connect.
Details: "ADO.NET: R execution timeout. The script execution was
terminated, since it was running for more than 1800000 miliseconds."
I have also tried specifying the full addresses of the csv files in read_csv(), but this results in the same timeout warning.
Any ideas as to how I can edit my script (or the settings in Power BI) to get around this? (The script only takes a minute or so to run in RStudio.)
Don't forget that you can load your csv file using the built-in functionalities in PowerBI Get Data > Text/CSV and then go to Edit Queries and handle the R scripting from there. That way you won't have to worry about setting the working directory in the R script at all.
You can even load multiple files and work on each and everyone of them using the approach described in Operations on multiple tables / datasets with Edit Queries and R in Power BI
Please let me know how this works out for you-

Is there a way to "update" RDS files by combining them with another RDS file?

I need to be able to merge RDS files so I do not have to run a SQL statement which takes 1 hour to run every day.
I have only been able to save and read separate RDS files. I am using R version 3.5.3 and I have not been able to find anything on updating files.
I tried merge(datafile1, datafile2) and this returned no data.

Automatic re-reading of the source file with shinyapps.io

I have an application, where I need to update the source data periodically. Source datafile is a csv file normally stored in the project directory and read with read.csv. The csv. file is changed every day with the updates. The name of the file does not change...just few cases are added.
I need the application to re-read the source pdf file with some periodicity (e.g. once per day). I can do it with reactiveFileReader function and it works when I am running the application from Rstudio, but not after I deploy the application on the web with shinyapps.io.
Can this be even done, when I am not using my own server but shinyapps.io?

automating R script using Mac's Automator and Calendar

I have been trying to run a script automatically using the steps that I found online.
I am trying to run the following R script called AUTO.R
Here is what the script contains:
library(quantmod)
obs <- last(Ad(getSymbols("SPY", auto.assign=FALSE)))
saveRDS(obs, "SAMPLE.rds")
When I build the application it prints Workflow completed
I believe all is well until the time comes to run the script. The alarm pop-up in my desktop is displayed from Calendar but nothing runs. After a few minutes the folder where the .rds file should be saved does not contain anything.
Two suggested changes:
Your Automator task should be more like just /usr/local/bin/Rscript --vanilla /Users/rimeallthetime/Desktop/AUTO.R
You should explicitly set the path in saveRDS; i.e. saveRDS(obs, "/Users/rimeallthetime/Desktop/SAMPLE.rds")
Honestly, though, you should at least make a ~/bin dir (i.e. a directory called bin under your home directory, so in your case /Users/rimeallthetime/bin and put both the workflow and R script in there, and I'd also suggest creating another directory for output files vs the desktop.
UPDATE
I just let the calendar event run and this is really a crude way to automate what you want to do. You'd be better off in the long run using launchd, that way it's fully automated and requires no human intervnention at all (but you may need to adjust your script to send you a notification or "append" to the rds file).

Resources