0

I built a Power BI report page with some R visuals (by using ggplot and scale etc.). The visuals display well on power bi desktop, but after being published to my workspace on power bi service, the R scripted visuals all have runtime error:

Error in label_number(prefix = "$", suffix = "M", scale = 1e-06, big.mark = ",") :

could not find function "label_number"

Below are the codes I wrote for one of the visuals

# dataset <- data.frame(Project #, Name, Portfolio,  OC, Hours, Cost)
# dataset <- unique(dataset)

# Paste or type your script code here:
library(tidyverse)
library(readxl)
library (dplyr)
library(tidyr)
library(lubridate)
library(ggplot2)
library(scales)
library(ggrepel)

plot1 <- dataset %>%
ggplot(mapping = aes(x = Cost, y = OC, size = Cost, label = Name ), varwith = TRUE )+
geom_point() +
geom_smooth () +
scale_x_continuous (labels = label_number(prefix = "$", suffix = "M", scale = 0.000001, big.mark = ",")) +
scale_y_continuous(labels = label_number(prefix = "$", suffix = "M", scale = 0.000001, big.mark = ","))+
scale_size_continuous (labels = label_number(prefix = "$", suffix = "M", scale = 0.000001, big.mark = ",")) + 
geom_text_repel(box.padding = 0.3, point.padding = 0.3, size = 3)+
labs(x = "Project Cost", y = "Owners Cost") +
theme (legend.position = "bottom")

plot1

Appreciate any help in advance! visual displayed on power bi desktop with the codes error message after being published

Google searched but could not find any resource related to this specific problem.

  • Welcome to StackOverflow. Can you make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by providing at least a portion of your dataset or using a sample dataset (e.g., `mtcars`)? – jrcalabrese Dec 11 '22 at 19:09

1 Answers1

0

When googling, include the official documentation:

R packages that are supported in Power BI

Peter
  • 10,959
  • 2
  • 30
  • 47
  • Thanks for your answer Peter. I have checked this document and can confirm that all the packages loaded in my codes are supported in Power BI. Especially when the error message points to "label_number" argument included in the "scale" package, it is odd because scale package is supported. – november_sky Dec 12 '22 at 16:53
  • 1
    I looked further into this problem and with the help of a R instructor in my organization, I realized that it still has everything to do with the version of the package not being supported by Power BI. According to the official document, Power BI currently supports version 1.0.0 of the scale package, but the "label_bumber" function has only become available in version 1.1.0 and above. The solution would be using a function that's available in version 1.0.0 of scale package or from a different package. – november_sky Dec 21 '22 at 17:30