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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Not able to install R library in PowerBI

Hi, 

 

I am trying to install R library in PowerBI R editor

 

If i write: 

install.packages('mice', lib=.libPaths())
I get error message that
the lib element  C:\Program Files\R\R-3.6.2\library is not a writable directory
 
If i write
install.packages('mice')
I get
 
Error Message:
R script error.
Installing package into 'C:/Users/my name/Library'
(as 'lib' is unspecified)
Error in contrib.url(repos, "source") :
trying to use CRAN without setting a mirror
Calls: install.packages -> contrib.url
Execution halted
 
If i write
install.packages("plotrix", lib = "C:/Program Files/R/R-3.6.3/library")
I get the same error message as above.
What should I do???
 
Thanks in advance!
11 REPLIES 11
ImkeF
Community Champion
Community Champion

Why do you want to install it via Power BI?

Power BI performs actions that are repeatable (i.e.regular data refreshes) but you'd normally install a package just once.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Is it possible to use library out of Powerbi and still use it in Powerbi? How to do that? When I install library in R studio, it is saved in a temp folder as I can see... and not possible to use it in powerbi...

ImkeF
Community Champion
Community Champion

Change the installation path in R Studio to the path that you've entered in your PBI settings:

 image.png

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Do you mean C:\Program Files\R\R-3.6.2\library? But i just found this folder is read only and however i change it to writable, it will be changed back automatically...

ImkeF
Community Champion
Community Champion

Sorry, I might have given the wrong advice here.

My R-libraries are installed in a local folder in the documents-path of my user.

 

I don't understand the details behind it, so hopefully someone else jumps in here.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

hmmm... what do u mean? you mean you R libraries, were downloaded via R studio, saved in a local folder, and you can use them in PowerBI??? How does that work? Where did you save them and how did you let PowerBI know where they are?

ImkeF
Community Champion
Community Champion

Actually, I didn't let Power BI know where they are.

Instead I just "told" R-Studio where they are: 

 

image.png

 

 

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

I have exactly the same setting in R studio as you do and in Powerbi options...

 

how come it doesnt work for me? 

 

Did you just write install.packages('name_of_lib') in R script editor in Powerbi? See the initial post, I have tried different combinitions and still doesnt work...

ImkeF
Community Champion
Community Champion

Hi @Anonymous 

I have NEVER installed any package through Power BI.

I'm always using R-Studio to install my packages.

Unfortunately I have no idea why - if you also intall your packages through R-Studio- Power BI would not recognize them.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

I followed this post, but when I finish step 5, a new R studio session will be opened for me, but it is totally blank and does not carry any variable from Powerbi into it... 

 

https://docs.microsoft.com/en-us/power-bi/desktop-r-ide

ImkeF
Community Champion
Community Champion

Hi @Anonymous 

I'm not using this functionality, so cannot give any tips on that, unfortunately.

 

.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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