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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

R visual error - "package '...'was installed by an R version with different internals"

Hi, 

 

I ran into this issue displaying an R visual in Power BI desktop. The script works fine in RStudio, and also on powerbi.com

 

The error I get is: 

Error Message:
R script error.
Error: package or namespace load failed for 'ggplot2':
 package 'scales' was installed by an R version with different internals; it needs to be reinstalled for use with this R version

 

This is what the script looks like. It's a simple test of showing an R visual in Power BI. 

  

I created a report with a R visual, with this script:

library(ggplot2)
ggplot(dataset, aes( x =dataset$lotsize, y=dataset$price)) + geom_point(shape=1) + geom_smooth()

 

The ggplot2 package is installed in the R home\library folder. So is the scales package. 

 

Can you please investigate and solve this? 

Status: New
Comments
waltheed
Solution Supplier

I got it to work with an older R version (R-3.4.4, March 2018).

 

I did not work with the current version (R-3.5.1, July 2018) or the previous version (R-3.5.0, April 2018).

 

Still there is an issue in Power BI Desktop: why is it working in RStudio and not in Power BI Desktop while they are using the same R installation?

 

v-qiuyu-msft
Community Support

Hi @waltheed,

 

I'm not able to reproduce the issue on my side.

 

q5.PNG

 

In your scenario, please check if "ggplot2" package already installed for R version 3.5.1. If it is, please uninstall it follow: https://stackoverflow.com/questions/26573368/uninstall-remove-r-package-with-dependencies. Then install the "ggplot2" package for R 3.5.1 and test again in Power BI desktop. 

 

q6.PNG

 

Best Regards,
Qiuyun Yu 

Haydeh
Frequent Visitor

Hi everyone,

 

I have the same error. although I have updated my R version to R-3.5.1 and in Options menue the

Detected R home directorirs is allighned with R version, still get this error mesege:

(Note: All packages are installed as well).

The Dumbbell graph used to be visualised fine with R.3.2 but when I upgraded R to 3.5.1 I get this error.

 

any support is appreciated,

 

Haydeh

 

Feedback Type:
Frown (Error)

Timestamp:
2018-10-01T20:28:41.9686831Z

Local Time:
2018-10-01T13:28:41.9686831-07:00

Session ID:
243cb8bd-b8e3-4c86-bd6d-b43ad33f58a6

Release:
September 2018

Product Version:
2.62.5222.761 (18.09) (x64)

Error Message:
R script error.
Loading required package: XML
Error: package or namespace load failed for 'XML':
package 'XML' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Warning message:
In libraryRequireInstall("XML") :
*** The package: 'XML' was not installed ***
Loading required package: htmlwidgets
Error: package or namespace load failed for 'htmlwidgets':
package 'htmltools' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Warning message:
In libraryRequireInstall("htmlwidgets") :
*** The package: 'htmlwidgets' was not installed ***
Loading required package: ggplot2
Error: package or namespace load failed for 'ggplot2':
package 'scales' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Warning message:
In libraryRequireInstall("ggplot2") :
*** The package: 'ggplot2' was not installed ***
Loading required package: plotly
Loading required package: ggplot2
Error: package or namespace load failed for 'ggplot2':
package 'scales' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Failed with error: 'package 'ggplot2' could not be loaded'
Warning message:
In libraryRequireInstall("plotly") :
*** The package: 'plotly' was not installed ***
Loading required package: ggplotly
Warning messages:
1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called 'ggplotly'
2: In libraryRequireInstall("ggplotly") :
*** The package: 'ggplotly' was not installed ***
Loading required package: gapminder
Error: package or namespace load failed for 'gapminder':
package 'tibble' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Warning message:
In libraryRequireInstall("gapminder") :
*** The package: 'gapminder' was not installed ***
Loading required package: gsubfn
Loading required package: proto
Loading required package: magrittr
Loading required package: htmlwidgets
Error: package or namespace load failed for 'htmlwidgets':
package 'htmltools' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Warning message:
In libraryRequireInstall("htmlwidgets") :
*** The package: 'htmlwidgets' was not installed ***
Loading required package: XML
Error: package or namespace load failed for 'XML':
package 'XML' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Warning message:
....

Anonymous
Not applicable

Following up, this appears to be a problem unique to the htmltools library.  I'm able to load ggplot, but the Power BI visuals bomb out when attempting to load htmltools.  Maybe PowerBI is trying to load the library with its internal version? (C:\Program Files\Microsoft\MRO-3.3.2\)

 

Installation of htmltools library:

[Workspace loaded from ~/.RData]

> remove.packages("htmltools")
Removing package from ‘C:/Users/.../Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
> install.packages("htmltools")
Installing package into ‘C:/Users/.../Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/htmltools_0.3.6.zip'
Content type 'application/zip' length 660594 bytes (645 KB)
downloaded 645 KB

package ‘htmltools’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:\Users\...\AppData\Local\Temp\RtmpsfBP2w\downloaded_packages
> require(htmltools)
> 

 

Both RStudio and PowerBI are pointing to the same instance of R:

RStudio Option:

R version:
[Default] [64-bit] C:\Program Files\R\R-3.5.1

 

PowerBI Option:

Detected R home directories:
C:\Program Files\R\R-3.5.1

 

The relevant error log:

Loading required package: ggplot2
Loading required package: htmltools
Error: package or namespace load failed for 'htmltools':
 package 'digest' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Installing package into 'C:/Users/eyphn2w/Library'
(as 'lib' is unspecified)
trying URL 'http://cran.us.r-project.org/bin/windows/contrib/3.5/htmltools_0.3.6.zip'
Content type 'application/zip' length 660594 bytes (645 KB)
==================================================

Loading required package: htmltools
Error: package or namespace load failed for 'htmltools':
package 'digest' was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Error: could not install htmltools
Execution halted

 

ImkeF
Super User

same here

ImkeF
Super User

This is a bug and there is a workaround: https://www.thebiccountant.com/2019/05/02/bug-in-power-bi-r-scripts-package-was-installed-with-diffe...

But it would be great if Microsoft could fix it.

ashvin
Frequent Visitor

Hello,

 

I am unable to switch libraries as mentioned in the workaround suggested above

 

However I noticed that PowerBI tries to load packages from a different library path ("C:/User/User_name/Library" - in my case) when using the R visuals and I printed the list of libraries inside the Rvisuals using .libPaths() command. So after installing the packages into this new location, I am able to run my R scripts in Rvisuals without any issues. No more namespace conflicts.

 

 

Hope this helps!