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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

Issues with R scripts in Power BI

stimada community,

I've been trying to use the R script visual in power BI to work with some R visualizations. I've watched over 3 videos to use these R scripts, but I have a basic problem that won't let me move forward.

In the image below you can see that I have uploaded 3 columns from a database to the R script, but these are not automatically loaded to the R script as is often the case in all the videos I have seen.

AlexisCab1602_0-1631219126593.png

This is an example of what should happen when loading the columns to the visual, in the R script the dataset is automatically updated with the contents of the different columns.

AlexisCab1602_1-1631219195505.png

I leave you the information of my R script configuration

AlexisCab1602_2-1631219337190.png

What am I doing wrong?

Stay tuned, thank you very much.

2 ACCEPTED SOLUTIONS
v-janeyg-msft
Community Support
Community Support

Hi, @Syndicate_Admin 

 

Do you create visual based on this tutorial? Are you sure that the R script in the background is running?

Create Power BI visuals using R - Power BI | Microsoft Docs

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

View solution in original post

Hi, @Syndicate_Admin 

 

Logically speaking, if the R script is successfully installed, it should be automatically generated. So I consider whether the version you installed is too high and powebi doesn't support it.

You can try to download the lower version.

vjaneygmsft_0-1631588767869.png

Reference:

Learn which R packages are supported - Power BI | Microsoft Docs

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi ,

 

I hope you can help me with the problem I have Re R scripting which is similar to this track 

 

I have  succesfully run many R scripts both in power Bi and the service.

 

My main problem is reading in RDS image file or even RDS csv compressed files in the service ..the sites are open public Github sites .. all code works in the desktop ..even reading from all the github sites  IN THE VISUAL R SCRIPTS . But when I run it in the service to the same sites it keeps saying the following

 

with the following code in the R visual :

 

 
 
I get the following error

 

Error in gzfile(file, "rb") : cannot open the connection In addition: Warning message: In gzfile(file, "rb") : cannot open compressed file 'https://github.com/gbortz27/aizatron/blob/main/mytitanic.rds?raw=true', probable reason 'No such file or directory exists"

 

OR with this code 

 

 

url4="https://github.com/gbortz27/aizatron/blob/main/mytitanic.rds?raw=true"

#data <- readRDS(url(url4, method="libcurl"))

#data=readRDS(gzcon(url(url4)))

data=read_rds(url4)

ggplot(data,aes(x=Age,y=Fare)) +geom_point()

 

 

 

url4="https://github.com/gbortz27/aizatron/blob/main/mytitanic.rds?raw=true"

data <- readRDS(url(url4, method="libcurl"))

#data=readRDS(gzcon(url(url4)))

#data=read_rds(url4)

ggplot(data,aes(x=Age,y=Fare)) +geom_point()

 

 

 

 
 
I get this error

Script Runtime Error

Attaching package: 'dplyr' The following objects are masked from 'package:stats': filter, lag The following objects are masked from 'package:base': intersect, setdiff, setequal, union Loading required package: bitops Error in readRDS(url(url4, method = "libcurl")) : cannot open the connection to 'https://github.com/gbortz27/aizatron/blob/main/mytitanic.rds?raw=true' In addition: Warning message: In readRDS(url(url4, method = "libcurl")) : URL 'https://github.com/gbortz27/aizatron/blob/main/mytitanic.rds?raw=true': status was 'Couldn't resolve host name'
However when it comes to reading in the file from getdata in the R script I can read  in both RDS (compressed csv)  and csv files and process them in the Query editor FROM THE EXACT SAME URLS. So if thr Rscript in the Get data IN THE SERVICE is working from the same sites it should mean there is no problem with 
 
1) the versions of R in the service 
2) the access to the sites 
 
So why is the R visual script different to the Get data R script engine.
 
So one may ask , well then bring the data in via the Get Data script.
 
The problem is if its a ggplot image (compressed in RDS format)  , although it reads in the file (the compressed RDS Image ) it displays as a "blob" for want of a better word and I dont  know how to decompress the image in the Query editor ie unserialize the rds file into a data frame  , bring it into the R visual , and resconstruct the image in the visual R script.
 
One may ask :: why are you not generating the ggplot image from the raw data.
 
For 3 reasons: 
 
1) the absence of libraries in the service , for instance ..tidymodels, ggstatsplot and many others
2) the libraries in the service are outdated , specifically ggplot2 (one of the most popular libraries in R) 
3) the limited time give for the R visual to process
4) Size of Graphics
 
One may also ask that why cant you store them as png.. because RDS files can be stored in such as way as to make them interactive via another dataframe brought in independently. 
 
So in conclusion there is something different between the Rscripting in Get data and the R scripting in the R visual as per the access to github files. 
 
Is there an issue with my code ie should I change the readRDS parametres in the visual or it it some security setting in the Service that prevents access to the site.
 
I have also loaded the Github app and given the srrvice permission the access files in my public repository. It connected to the repository as it showed the my dashboard..but this made no difference to the success of accessing the data.
 

Hi @Anonymous 

 

This thread has been solved. If you have problems and are more complicated, I suggest you open a new thread. There will be other engineers to help you.

 

Best Regards,

Community Support Team _ Janey

v-janeyg-msft
Community Support
Community Support

Hi, @Syndicate_Admin 

 

Do you create visual based on this tutorial? Are you sure that the R script in the background is running?

Create Power BI visuals using R - Power BI | Microsoft Docs

 

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

I've done the tutorial you sent, and it works, but not as I expected.

AlexisCab1602_0-1631562195435.png

If you look at code line 3, I have manually added "dataset <- data.frame()" and within this I have not added any of the columns that appear in the visual on the right. Still, the code works, but I still do not understand the reason why the dataset is not created automatically with the columns that I am adding, it is a strange problem but at least now I can use some R libraries in Power BI. Thank you very much for the link, if you have information regarding why the dataset is not automatically generated I would appreciate it.

TomMartens
Super User
Super User

Hey @Syndicate_Admin ,

 

what happens if you remove the #-character that can be seen in line 3 of the R script?

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

If I delete only the # of line 3 it looks like this

AlexisCab1602_0-1631220768234.png

Columns added to the visual are still not added to the data.frame. Now, if I remove the entire line 3

AlexisCab1602_1-1631220830189.png

nothing happens either, I just run out of my data.frame. I don't understand why the data.frame doesn't update automatically when you add columns to the visual. What do you recommend I try?

Hi, @Syndicate_Admin 

 

Logically speaking, if the R script is successfully installed, it should be automatically generated. So I consider whether the version you installed is too high and powebi doesn't support it.

You can try to download the lower version.

vjaneygmsft_0-1631588767869.png

Reference:

Learn which R packages are supported - Power BI | Microsoft Docs

Did I answer your question ? Please mark my reply as solution. Thank you very much.
If not, please feel free to ask me.


Best Regards,

Community Support Team _ Janey

You're right, you have to wait for a Power BI update about it, despite this, I've been able to use the R scripts I needed. I have loaded the columns to the visual object and in line 3 I have put "# dataset<-data.frame()", line 4 I have not touched, and with this the dataset considers all the columns that I have incorporated into the visual object, although I do not mention them within the data.frame. Thank you very much for the information.

Best regards.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.