Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Starting with R in Power BI

Hello, 

 

I am at my first steps with R in Power BI.  I have installed R Studio 64 bit for windows. Also, I have installed R Open, version R-3.5.3 from Microsoft.

 

Also, I have load a PBIX to test my installation.

A copy of the project is available at:   https://onedrive.live.com/?authkey=%21AJ1XcXB95pETL2g&cid=CBDD37C1AF373511&id=CBDD37C1AF373511%21307...

 

The file on OneDrive is a zip file which include a PBIX file, an excel file (College Enrollment All Types of Students 14+),

a csv file (PowerPlants).

 

There is also another file in the project which is named Iris_Data.  I wrote to the author of the pbix in order to get a copy of this file

at sqlDusty@gmail.com.

 

If I obtain a copy of those files, it will be possible for me to refresh the dashboard.

 

If I want to read the csv file using R studio, I use the following script:

 

library(readr)

PowerPlants <- read_csv("P:/Document/Test/Testing R in Power BI/R Visual PBI data sources/PowerPlants.csv")

 

This script works in RStudio.

If I goes into Power Query Editor, then I select the query powerplants, the I click on Source, a R script window popup.  I enter exactly the same script and I go this error.

 

DataSource.Error: ADO.NET: R script error.
Error: 'P:/Document/Test/Testing R in Power BI/R Visual PBI data sources/PowerPlants.csv' does not exist.
Execution halted

Details:
DataSourceKind=R
DataSourcePath=R
Message=R script error.
Error: 'P:/Document/Test/Testing R in Power BI/R Visual PBI data sources/PowerPlants.csv' does not exist.
Execution halted

ErrorCode=-2147467259
ExceptionType=Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException

 

Please note that the first line alone works 

library(readr)  but not the second one

PowerPlants <- read_csv("P:/Document/Test/Testing R in Power BI/R Visual PBI data sources/PowerPlants.csv")

failed

 

As I am at my first steps in R.  I want to test the installation.  

Does someone know how to solve this issue.

 

 

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

Based on my test in Power BI Desktop, the R Script works fine for connect to data source using your code. Please check the data source because your error is the data source does not exist.

Starting with R in Power BI 1.PNG

Starting with R in Power BI 2.PNG

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

Based on my test in Power BI Desktop, the R Script works fine for connect to data source using your code. Please check the data source because your error is the data source does not exist.

Starting with R in Power BI 1.PNG

Starting with R in Power BI 2.PNG

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Hello,

 

I have made some tests to understand how works R in Power BI.

 

I have tried the following script which is not working

 

getwd()
work_dir <-"P:/Document/Test/Testing R in Power BI/R Visual PBI data sources"
setwd(work_dir)
getwd()
PowerPlants3 <- read.csv(file = 'PowerPlants.csv')

 

First, I found that it is better to use the unix convention to separate Directory and Path.  So we need to replace the back slash for the fore slash . Refer to this web page: https://pc.net/helpcenter/answers/backslash_vs_forward_slash

 

Also, it seems that R inside of Power BI does not recognize the Windows mapping such as P:

 

So the poper way to access a csv file on a server is by using a script as below:

 

work_dir <- "//myserverName/document/Test/Testing R in Power BI/R Visual PBI data sources"
setwd(work_dir)
PowerPlants <- read.csv(file = 'PowerPlants.csv')

 

 

Anonymous
Not applicable

Hello,

 

Could it be possible that I have an issue due to the fact that the csv file is located on a server not on my local machine?  If it is the case how do we solve this problem.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.