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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

dir.create in R is not working for Power BI service.

Hi,

 

I have a R visual which creates a directory in your local using dir.create(C:/foldername) and it is working fine in Power Bi desktop but same when deployed in Power Bi service, it is throwing me an error like C:/foldername does not exist. That means it is not creating directory. 

 

Could you please help me fix the solution for this.

 

Thanks,

Shubham

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Sorry for the delay. I may misunderstand your scenario before.

 

By my research for your sceanrio, I'm afraid that we cannot show your desired output in Power BI Service based on R scripts security.

 

  • R visuals are created from R scripts, which could potentially contain code with security or privacy risks.
  • These risks mainly exist in the authoring phase when the script author run the script on their own computer.
  • The Power BI service applies a sandbox technology to protect users and the service from security risks.
  • This sandbox approach imposes some restrictions on the R scripts running in the Power BI service, such as accessing the Internet, or accessing to other resources that are not required to create the R visual.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

 

By my tests with the latest version of Power BI Desktop, it seems that everything works as expected.

 

Untitled.png

 

Here is my setting.

 

setting.PNG

 

If you still need help, please share a dummy pbix file which can reproduce the issue, so that we can help further investigate on it? You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.)

 

You also could have a test with my test pbix file.

 

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks @v-piga-msft  for your reply.


RCode.PNG

 

My code works in a following : - first it will create a directory if it does not exists. then if it exisits then Message will be printed as  "Folder exists" else Message will be printed as "Folder does not exists". Ideally it should never go into else part because i am creating my direcory in the first line.

It does work fine in Power BI desktop as you can see the result in the above image itself.

When i publish to Power BI services, it does not creates the directory and falls in to the else part. Please find below image :

RCode_Service.PNG

 

Please find the below full R code and can you please replicate the same. Just copy-paste it into R visual script and pass 1 dummy column. It will be very helpful for me.

# Sheet name
ExportSheet    =  "Sheet 1"
# Appends data to existing file or overwrites existing fle
AppendToPreviousFile  = FALSE
# Includes header. Better to set to false if AppendToPreviousFile is TRUE
WithHeader    = TRUE  

### Export functions ##################################################################################

Message <- function(Text,Comment) { 
    
    par(mar=c(1,1,1,1)) 
    NoPlot = c(0) 
    barplot(NoPlot)
    plot(1:1, 1:1, main = "", sub = "", fg="white")
    text(1, 1.2, Text, cex = 2, fg="white")
    text(1, 0.8, Comment, cex = 1.5, fg="white")
    return()
}
ExportFile   = "C:/RData/AssetData.xlsx"
dir.create("C:/RData/")  #This creates a folder if not exists
ExportFolder = dirname(ExportFile)
if (dir.exists(ExportFolder)){     #If folder exists then execute below code
    Message("Folder  exist",ExportFolder)
} else {                           #else
    Message("Folder does not exist",ExportFolder)
}

 

Anonymous
Not applicable

@v-piga-msft  Could you please replicate the same and see if it is possible to solve or not. I really need help on this. 

 

Thanks in advance.

Hi @Anonymous ,

 

Sorry for the delay. I may misunderstand your scenario before.

 

By my research for your sceanrio, I'm afraid that we cannot show your desired output in Power BI Service based on R scripts security.

 

  • R visuals are created from R scripts, which could potentially contain code with security or privacy risks.
  • These risks mainly exist in the authoring phase when the script author run the script on their own computer.
  • The Power BI service applies a sandbox technology to protect users and the service from security risks.
  • This sandbox approach imposes some restrictions on the R scripts running in the Power BI service, such as accessing the Internet, or accessing to other resources that are not required to create the R visual.

Best  Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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