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
Anonymous
Not applicable

R Script Runtime Error

I created R visuals in Power BI. The visuals display well in Power BI desktop but show "Script Runtime Error" when I publish to workspace. 

 

Please try again later or contact support. If you contact support, please provide these details.
Activity ID: ecdf718c-d16d-4266-bf83-217dda91eff6
Request ID: 806fe02f-6e01-c85a-b453-7c6132a7c739
Correlation ID: 6398d10e-4794-abd3-9f02-1fb675609689
Time: Fri Sep 04 2020 11:47:14 GMT+0800 (Hong Kong Standard Time)
Service version: 13.0.14163.65
Client version: 2008.3.02479-train
Cluster URI: https://wabi-south-east-asia-redirect.analysis.windows.net/

 

 

Here is the R script:

library(scales)
P <- function (x) { number_format(accuracy = 1,
scale = 1*100,
suffix = "%",
big.mark = ",")(x) }
library(dplyr)
dataset2=dataset%>%
group_by(`School (Revised)`)%>%
mutate(percent=`No. of Students (headcount)`/sum(`No. of Students (headcount)`),
pos=cumsum(percent)-percent/2)

Academy=dataset%>%
group_by(GenderCode)%>%
summarise(`No. of Students (headcount)`=sum(`No. of Students (headcount)`))%>%
ungroup()%>%
mutate(percent=`No. of Students (headcount)`/sum(`No. of Students (headcount)`),
pos=cumsum(percent)-percent/2,
`School (Revised)`="Academy")

dataset2=rbind(dataset2,Academy)
total=dataset2%>%
group_by(`School (Revised)`)%>%
summarise(total=sum(`No. of Students (headcount)`))

library(ggplot2)
library(forcats)
ggplot(data=dataset2,aes(x=fct_rev(`School (Revised)`),y=percent))+
geom_bar(aes(fill=GenderCode),stat="identity", position = position_stack(reverse = TRUE))+coord_flip()+
geom_text(aes(label=`No. of Students (headcount)`,y=pos,vjust=-0.3),size=5,color="black",family="serif")+
geom_text(aes(label=paste("(",P(percent),")",sep=""),y=pos,vjust=1),size=5,color="black",family="serif")+
geom_text(data=total,aes(label=total,y=1.05),size=5,color="black",family="serif")+
scale_y_continuous(labels=P,limits=c(0,1.08),expand=c(0,0))+
scale_fill_manual(values=c("#C05046","#4F81BD"))+
labs(fill = "Gender")+
theme(legend.text = element_text(size=11),
legend.position="top",
legend.justification='left',
legend.direction = "horizontal",
panel.background = element_blank(),
axis.title=element_blank(),
axis.text.x = element_text(size = 14),
axis.text.y = element_text(size = 14))
2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey @Anonymous ,

 

make sure that you are using features from the packages that are supported by the versions available at the Power BI Service, this link lists the supported packages and their versions:

https://docs.microsoft.com/en-us/power-bi/connect-data/service-r-packages-support

 

Sometime ago, I was using a feature from the scales package, after "downgrading" the code in my R script everything was working as expected. Maybe this is the same here.

 

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

View solution in original post

Anonymous
Not applicable

@Anonymous

 

For this kind of unknown error that we cannot reproduce, you can create a support ticket.

BTW, R scripts are supported only for personal gateway mode: https://docs.microsoft.com/en-us/power-bi/connect-data/power-bi-data-sources

 

Paul Zheng _ Community Support Team
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

2 REPLIES 2
Anonymous
Not applicable

@Anonymous

 

For this kind of unknown error that we cannot reproduce, you can create a support ticket.

BTW, R scripts are supported only for personal gateway mode: https://docs.microsoft.com/en-us/power-bi/connect-data/power-bi-data-sources

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
  

TomMartens
Super User
Super User

Hey @Anonymous ,

 

make sure that you are using features from the packages that are supported by the versions available at the Power BI Service, this link lists the supported packages and their versions:

https://docs.microsoft.com/en-us/power-bi/connect-data/service-r-packages-support

 

Sometime ago, I was using a feature from the scales package, after "downgrading" the code in my R script everything was working as expected. Maybe this is the same here.

 

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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