Forum Discussion
np212r
8 years agoRegular Visitor
Rscript runs fine in Rstudio not in PowerBi
This script below runs fine in Rstudio but gives me ENVSXP error in PowerBi. Could anyone figure out why? library(anomalize) library(dplyr) sub= tidyverse_cran_downloads %>% time_decompos...
patricio_lagos
4 years agoRegular Visitor
np212r Hi. I run into the very same problem. Power bi's r script was not working for the time_decompose function.
I found a way around it. I gave up running the script. Instead, I used the "r visual opbject" . In there, I ran pretty much the same code:
df=dataset
library(dplyr)
library(devtools)
library(lubridate)
library(zoo)
library(tidyquant)
library(ggplot2)
library(anomalize)
df=df[complete.cases(df$HZ),]
df=df[complete.cases(df$FECHA),]
row.names(df) <- NULL
df=as_tibble(df)
df$FECHA=as.Date(df$DATE)
plot(df$FECHA,df$y)
df1=df %>%
ungroup() %>%
time_decompose(y) %>%
anomalize(remainder) %>%
time_recompose()
ggplot(df1, aes(x = DATE, y = observed, color = anomaly)) +
geom_point(size = 3)
as you can see, I did not plot the time series with the plot_anomalies function, but rather used ggplot.
Hope it helps