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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
np212r
Regular 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_decompose(count) %>%
  anomalize(remainder)

 
5 REPLIES 5
patricio_lagos
Regular 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

 

CrisSalgado
Frequent Visitor

Hi, @np212r 

Could you solve this problem?

I'm using dplyr to

datafromAccess<-datafromAccess %>% #(lf)
        group_by(Slot, Period) %>% #(lf)
        mutate(colDiff= colValue - colValue[OrdemNum==1]

but results an error Error: Column `colDiff` must be length 1 (the group size), not 0

and many "warnings" : 

    Attaching package: 'dplyr'

            The following objects are masked from 'package:stats':

                    filter, lag

            The following objects are masked from 'package:base':

                    intersect, setdiff, setequal, union

The code works perfectly in R Studio, the dplyr version is 0.8.0.1 (that is supposed to be supported by PowerBI) and the package is installed in the same path of others (like RODBC and stringr) that works fine. 

Best Regards

Cristiane

v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @np212r,

After research, there are the following thread and article for reference.

Getting Power BI Desktop to see R packages?
R Script error
Running Local R Scripts in Power BI

Best Regards,
Angelia

That did not work. Were you able to run the code I had put in my question?

Hi @np212r,

Did you configurate the R in Power BI desktop?

Best Regards,
Angelia

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.