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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

undefined R Script Runtime error on Web application Power BI

Hi,

I wrote R code to make a bar graph and display it in My Workspace in Power BI. The code works on the desktop version of Power BI Pro.tawanda2024_0-1727203722899.png

 

I published it to My Workspace and it no longer displays. The dataset has ~ 28Krecords. I get this error:

Script Runtime Error

An error occurred while running the script

Activity ID: 262bfad0-7d3d-49c9-aaaf-40cfad9c5bb2

Request ID: 6b1c213c-d4f0-447b-b8c7-e245ce3025b9

Correlation ID: 39434e9a-5308-0b04-deb3-383f159ba35d

Time: Tue Sep 24 2024 11:51:33 GMT-0400 (Eastern Daylight Time)

Service version: 13.0.24157.39

Client version: 2409.1.20849-train

Cluster URI: https://wabi-us-gov-iowa-redirect.analysis.usgovcloudapi.net/

 

I've copied my R code and a sample dataframe below.

 

Any help would be greatly appreciated.

Thank you,

 

 

Here is the R script:

 

 

library(dplyr, exclude = c("filter", "lag"))
library(ggplot2)

powerbi_rEnableShowText = 1

df <- dataset %>% 
  group_by(long_path_name) %>% 
  summarize(Freq = n()) %>% 
  arrange(desc(Freq)) %>% 
  ungroup() %>% 
  mutate(count_pathogens = sum(Freq), 
         pct_of_total = round(Freq/count_pathogens* 100 , digits = 1)) %>% 
  head(5)

 x_axis_size = round(max(df$pct_of_total), digits = 0) + 4
 
positions <-  df$long_path_name

ggplot(data=df, aes(x=pct_of_total, y=long_path_name, width=.5))+ 
  theme_classic() +
  geom_bar(stat="identity", fill="#118DFF")+ 
  scale_y_discrete(limits = rev(positions)) +
  geom_text(aes(label=paste0(pct_of_total, "% (", Freq, ")" )),
            hjust =-.05, 
            color="black", size=5) +
  theme(line = element_blank(),
        axis.text.y = element_text(face = "italic", size = 15, color = "black"), 
        axis.title.y = element_blank(), 
        text = element_text(size = 20), 
        plot.title = element_text(size = 20, face = "bold"), 
        axis.ticks=element_blank())+ 
  #xlab("Percent of Pathogens") + 
  ggtitle("Percent (Number) of HAI Pathogens")+ 
  expand_limits(x = c(0, x_axis_size), 
                y = c(0,0)) + 
  scale_x_continuous(breaks=seq(0, x_axis_size, 2), 
                     name = "Percent of Pathogens")+
  theme(panel.border = element_blank(),
 #   panel.grid.major.x = element_line(size = 0.5, linetype = 'solid',
  #                                  colour = "grey")
  )

 

 

 

Here is sample data only from 2017 

 

keyyearhaipath_namelong_path_namehai_copy
12017clabsiECE. coliCLABSI
22017clabsiPAP. aeruginosaCLABSI
32017clabsiENTFSE. faecalisCLABSI
42017clabsiPMP. mirabilisCLABSI
52017clabsiKPK. pneumoniaeCLABSI
62017cautiECE. coliCAUTI
72017cautiPAP. aeruginosaCAUTI
82017cautiENTFSE. faecalisCAUTI
92017cautiPMP. mirabilisCAUTI
102017cautiKPK. pneumoniaeCAUTI
112017COLOECE. coliCOLO
122017COLOPAP. aeruginosaCOLO
132017COLOENTFSE. faecalisCOLO
142017COLOPMP. mirabilisCOLO
152017COLOKPK. pneumoniaeCOLO
162017HPROECE. coliHPRO
172017HPROPAP. aeruginosaHPRO
182017HPROENTFSE. faecalisHPRO
192017HPROPMP. mirabilisHPRO
202017HPROKPK. pneumoniaeHPRO
212017KPROECE. coliKPRO
222017KPROPAP. aeruginosaKPRO
232017KPROENTFSE. faecalisKPRO
242017KPROPMP. mirabilisKPRO
252017KPROKPK. pneumoniaeKPRO
262017HYSTECE. coliHYST
272017HYSTPAP. aeruginosaHYST
282017HYSTENTFSE. faecalisHYST
292017HYSTPMP. mirabilisHYST
302017HYSTKPK. pneumoniaeHYST
Status: Needs Info
Comments
Anonymous
Not applicable

Hi  @tawanda2024 

I tried to restore the scenario you mentioned but failed, can you provide your sample for reference ?

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

vyetao1msft_0-1727251583705.png

 

Best Regards,
Community Support Team _ Ailsa Tao

tawanda2024
Regular Visitor