Forum Discussion
Getting Power BI Desktop to see R packages?
- 9 years ago
I removed my user library, installed packages at C:/Program Files/MRO-3.3.2/library, and changed Rstudio's library path with .libPaths(). But then I realized that even after doing this, I still needed to load packages in Rstudio before I was able to use them. I thought the library would be scanned and packages were autoloaded, which turns out to be an incorrect assumption.
So, whether in Rstudio or from Power BI's R script editor, you need to explicitly load the package before using it:
library("stringr", lib.loc="C:/Program Files/MRO-3.3.2/library") sum(str_count(dataset, "my string"))Edit: the lib.loc local path will obviously not work once you publish to the cloud service. This is not necessary if the path for the R environment is properly set in Power BI Desktop settings.
Also, if you're going nuts because PBI is complaining about outdated packages/dependencies even though RStudio shows you have the correct (latest) version, read this:
http://blog.datainspirations.com/2018/02/02/power-bi-r-home-directory-vs-library-trees/
I removed my user library, installed packages at C:/Program Files/MRO-3.3.2/library, and changed Rstudio's library path with .libPaths(). But then I realized that even after doing this, I still needed to load packages in Rstudio before I was able to use them. I thought the library would be scanned and packages were autoloaded, which turns out to be an incorrect assumption.
So, whether in Rstudio or from Power BI's R script editor, you need to explicitly load the package before using it:
library("stringr", lib.loc="C:/Program Files/MRO-3.3.2/library")
sum(str_count(dataset, "my string"))
Edit: the lib.loc local path will obviously not work once you publish to the cloud service. This is not necessary if the path for the R environment is properly set in Power BI Desktop settings.
Also, if you're going nuts because PBI is complaining about outdated packages/dependencies even though RStudio shows you have the correct (latest) version, read this:
http://blog.datainspirations.com/2018/02/02/power-bi-r-home-directory-vs-library-trees/
HI
I had a similar issue. The following worked but is far from being the ideal soloution.
PowerBI tries to use the system user to conect with Rstudio. So I ran both powerBI and Rstudio as Adminisrator (right click on the program). I installed the required libraries in R studio into the system library using:;
install.packages('packagname','C:/Program files/R/R-3.3.3/library)
and invoked the libraries from powerBI and that worked.
Tried other ways to maintain all intercations with the username as myself but that did not work.