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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

R package 'forecast' works on Desktop but not on service

Hi,

 

I am using the forecast package to forecast our sales. It works perfectly on Power BI Desktop but not when I upload my report to the Power BI service. The error says 'Visual is loading a package with a dependency that is currently unavailable'. I am only using forecast package in my script and it is present in the list of currently supported packages. I am also using read.csv to grab data from a web link. Can that cause a problem?

 

image.png

Status: Needs Info
Comments
v-haibl-msft
Employee

@peeyushp

 

Could you please provide your PBIX file to me? I'd like to take a look and try it locally.

 

Best Regards,
Herbert

Vicky_Song
Impactful Individual
Status changed to: Needs Info
 
peeyushp
Frequent Visitor

 @v-haibl-msft I cannot share the PBIX file since it's connected to our SQL Server database and has confidential information. I can share my R script though, which is attached.

options(scipen = 999)
library(forecast)
sales <- dataset
colnames(sales) <- c("Typed", "Date")
sales$Date <- as.Date(sales$Date)
sales <- sales[1: length(sales[ ,1]) - 1, ]
maxyear <- as.numeric(substring(tail(sales$Date, 1), 1, 4))
maxmonth <- as.numeric(substring(tail(sales$Date, 1), 6, 7))
maxmonth1 <- function (x) {
y <- x - 1
ifelse(y == 0, 12,
	ifelse(nchar(y) == 2, return(y), return(paste("0", y, sep = ""))))
}
monthurl <- maxmonth1 (maxmonth)
url <- paste("https://fred.stlouisfed.org/graph/fredgraph.csv?chart_type=line&recession_bars=on&log_scales=&bgcolor=%23e1e9f0&graph_bgcolor=%23ffffff&fo=Open+Sans&ts=12&tts=12&txtcolor=%23444444&show_legend=yes&show_axis_titles=yes&drp=0&cosd=1963-01-01&coed=", maxyear, "-", monthurl, "-", "01&height=450&stacking=&range=&mode=fred&id=MSACSR&transformation=lin&nd=1963-01-01&ost=-99999&oet=99999&lsv=&lev=&mma=0&fml=a&fgst=lin&fgsnd=2009-06-01&fq=Monthly&fam=avg&vintage_date=&revision_date=&line_color=%234572a7&line_style=solid&lw=2&scale=left&mark_type=none&mw=2&width=1168", sep = "")
msacsr <- read.csv(url)
msacsr$DATE <- as.Date(msacsr$DATE)
mergeddata <- merge(sales, msacsr, by.x = "Date", by.y = "DATE", all.x = TRUE)
last5years <- tail(mergeddata, 60)
lagpad <- function(x, k) {
  if (!is.vector(x)) 
    stop('x must be a vector')
  if (!is.numeric(x)) 
    stop('x must be numeric')
  if (!is.numeric(k))
    stop('k must be numeric')
  if (1 != length(k))
    stop('k must be a single number')
  c(rep(NA, k), x)[1 : length(x)] 
}
last5years$lag4 <- lagpad(last5years$MSACSR, 4)
salests <- ts(last5years[, 2:4], end = c(maxyear, maxmonth), frequency = 12)
xregs <- tail(last5years$MSACSR, 4)
fit <- auto.arima(salests[ ,1], xreg = salests[, 3])
plot(forecast(fit, xreg = xregs), main = "Sales Forecast for the next three months", include = 36)

 

Jared_Marx
Regular Visitor

I am experiencing a very similar issue using the packages ggmap, ggplot2, and dplyr.  I am also accessing an external data source within R by calling the get_map( ) function. Similarly, I see the image render in Desktop but not in the service with the same error message.