Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe'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
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.
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
| key | year | hai | path_name | long_path_name | hai_copy |
| 1 | 2017 | clabsi | EC | E. coli | CLABSI |
| 2 | 2017 | clabsi | PA | P. aeruginosa | CLABSI |
| 3 | 2017 | clabsi | ENTFS | E. faecalis | CLABSI |
| 4 | 2017 | clabsi | PM | P. mirabilis | CLABSI |
| 5 | 2017 | clabsi | KP | K. pneumoniae | CLABSI |
| 6 | 2017 | cauti | EC | E. coli | CAUTI |
| 7 | 2017 | cauti | PA | P. aeruginosa | CAUTI |
| 8 | 2017 | cauti | ENTFS | E. faecalis | CAUTI |
| 9 | 2017 | cauti | PM | P. mirabilis | CAUTI |
| 10 | 2017 | cauti | KP | K. pneumoniae | CAUTI |
| 11 | 2017 | COLO | EC | E. coli | COLO |
| 12 | 2017 | COLO | PA | P. aeruginosa | COLO |
| 13 | 2017 | COLO | ENTFS | E. faecalis | COLO |
| 14 | 2017 | COLO | PM | P. mirabilis | COLO |
| 15 | 2017 | COLO | KP | K. pneumoniae | COLO |
| 16 | 2017 | HPRO | EC | E. coli | HPRO |
| 17 | 2017 | HPRO | PA | P. aeruginosa | HPRO |
| 18 | 2017 | HPRO | ENTFS | E. faecalis | HPRO |
| 19 | 2017 | HPRO | PM | P. mirabilis | HPRO |
| 20 | 2017 | HPRO | KP | K. pneumoniae | HPRO |
| 21 | 2017 | KPRO | EC | E. coli | KPRO |
| 22 | 2017 | KPRO | PA | P. aeruginosa | KPRO |
| 23 | 2017 | KPRO | ENTFS | E. faecalis | KPRO |
| 24 | 2017 | KPRO | PM | P. mirabilis | KPRO |
| 25 | 2017 | KPRO | KP | K. pneumoniae | KPRO |
| 26 | 2017 | HYST | EC | E. coli | HYST |
| 27 | 2017 | HYST | PA | P. aeruginosa | HYST |
| 28 | 2017 | HYST | ENTFS | E. faecalis | HYST |
| 29 | 2017 | HYST | PM | P. mirabilis | HYST |
| 30 | 2017 | HYST | KP | K. pneumoniae | HYST |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.