1

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.)

Mel
  • 700
  • 6
  • 31

1 Answers1

0

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-

vestland
  • 55,229
  • 37
  • 187
  • 305