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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
puskas63
Regular Visitor

R in power bi

When using R in power bi, I get the following error

Details: "ADO.NET: R script error.
Error in setwd("~/Documents/R") : cannot change working directory
Calls: .First -> options -> setwd

Can you please help me?

Cheers Jeff.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @puskas63 ,

try below steps

  1. Check the directory path: Verify that the directory "/Documents/R" exists and is accessible. Ensure that the tilde () is correctly interpreted as your home directory. You can try providing an absolute path instead, such as "C:/Users/YourUsername/Documents/R", to ensure accuracy.

  2. Verify permissions: Make sure you have the necessary permissions to access and modify the directory. Ensure that you have read and write permissions for the directory "~/Documents/R" or the absolute path you're using.

  3. Use a different working directory: Instead of changing the working directory in your R script, consider using absolute paths for any files or directories you need to access within your script. This eliminates the need to change the working directory and avoids potential issues related to directory changes.

  4. Check R runtime environment: Ensure that the R runtime environment in Power BI has the necessary privileges to modify directories. You may need to consult your IT department or system administrator to verify the R runtime environment's permissions.

  5. Try a different location: If changing the working directory is not essential for your script, you can try running it without modifying the directory. This approach avoids potential conflicts related to directory changes.

  6. Update R packages: Make sure you have the latest versions of R packages installed in your R environment. Outdated packages might cause compatibility issues or unexpected behavior.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @puskas63 ,

try below steps

  1. Check the directory path: Verify that the directory "/Documents/R" exists and is accessible. Ensure that the tilde () is correctly interpreted as your home directory. You can try providing an absolute path instead, such as "C:/Users/YourUsername/Documents/R", to ensure accuracy.

  2. Verify permissions: Make sure you have the necessary permissions to access and modify the directory. Ensure that you have read and write permissions for the directory "~/Documents/R" or the absolute path you're using.

  3. Use a different working directory: Instead of changing the working directory in your R script, consider using absolute paths for any files or directories you need to access within your script. This eliminates the need to change the working directory and avoids potential issues related to directory changes.

  4. Check R runtime environment: Ensure that the R runtime environment in Power BI has the necessary privileges to modify directories. You may need to consult your IT department or system administrator to verify the R runtime environment's permissions.

  5. Try a different location: If changing the working directory is not essential for your script, you can try running it without modifying the directory. This approach avoids potential conflicts related to directory changes.

  6. Update R packages: Make sure you have the latest versions of R packages installed in your R environment. Outdated packages might cause compatibility issues or unexpected behavior.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors