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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
OPS-MLTSD
Post Patron
Post Patron

Error in file(filename, "r", encoding = encoding) : cannot open the connection Calls: source -> file

Hello,

 

I am trying to import an R script into power BI, I tested the script in R and it works perfectly fine but when I try to import it to power bi using "get data -> r script", this is the message I get:

 

OPSMLTSD_0-1686683285215.png

 

 

Here is the script I try to load into R script in Power BI:

 

 

actualLibPaths <- as.data.frame(.libPaths(.libPaths()[3]))
source(here::here("subfolder1", "subfolder2", "subfolder3", "subfolder4", "subfolder5", "script.R"))


output <- script_last %>%
group_by(actual_month) %>%
summarise(location = "main",
total_all = sum(total)
) %>%
bind_rows(script_last) %>%
mutate(id = row_number())

 

It is not a big script and nothing too complicated. I ran it in R before loading into power bi and everything is working just fine in R, however, I am not sure why i am getting that message, everything is set up just fine in power bi:

 

OPSMLTSD_2-1686662512783.png

 

 

 

if someone could please help, I would really appreciate that

 

 

EDIT:

I changed my script in r script editor in power bi to just this:

 

source("C:/Users/MyUserName/folder1/subfolder1/subfolder2/subfolder3/subforlder4/script.R")

I tested it in R first and it works just fine but when I import to r script in power bi, this is the new message I get:

 

OPSMLTSD_0-1686757793142.png

 

We encountered an error while trying to connect. Details: "SYMSXP"

 

I have no idea how to solve this, the error message is not very helpful, if someone could please help, I would appreciate that

 

4 REPLIES 4
v-shex-msft
Community Support
Community Support

HI @OPS-MLTSD,

I'd like to suggest you double-check the current account and permission configurations to ensure if you and power bi desktop client have enough permissions to access initiation path/folder of R script.

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft  thanks, is there a way I can check?

HI @OPS-MLTSD,

Normally you can enter the parent folder of the configured path and right click on the folder and choose 'properties'. Then you can navigate the 'security' tab to check corresponded permission setting of different users.

How to Set File and Folder Permissions in Windows (online-tech-tips.com)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft  thank you I will try this solutiona nd get back.

 

Meanwhile, I figured out why I am getting this error message:

We encountered an error while trying to connect. Details: "SYMSXP"

 

It is because I have a package in my r script not supported as part of the R packages supported by Power BI: Learn which R packages are supported - Power BI | Microsoft Learn

The package is called fpp3 - used for time series forecasting.

 

If anyone could tell me how I can contact Power BI - R support to get the package added, that would be much appreciated

 

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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