Forum Discussion

webportal's avatar
webportal
Impactful Individual
5 years ago

Error: package or namespace load failed for 'ggplot2': package 'ggplot2' was installed before R 4.0.

I'm really stuck and need some help.

After installing R 4.0.2, I'm getting this error message on R visualizations in Power BI Desktop which were previously working

"Error: package or namespace load failed for 'ggplot2':
 package 'ggplot2' was installed before R 4.0.0: please re-install it.
 Execution halted"

I already tried to:

reinstall R 4.0.2reinstall RStudio

reinstall ggplot2 

reinstall all packages

reinstall Power BI Desktop. My version is August-2020

Still it does not work.

Considerations:

My visualizations were working well before I installed R 4.0.2My visualizations are working well on other PCs

When I run the code on RStudio I don't get any error

Any thoughts?

8 Replies

  • v-diye-msft's avatar
    v-diye-msft
    Community Support

    Hi webportal 

     

    Try below solution:

    Find the root folder of R :

    Run it and input : 

    install.packages("ggplot2")

    then enter "yes>yes.." until finished.

    • webportal's avatar
      webportal
      Impactful Individual
      Hi,
      Sure; I did that as per my post above.
    • dpombal's avatar
      dpombal
      Post Partisan

      Not worked for me

       


      Stack Trace:
      Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: Error del script R.
      Error: package or namespace load failed for 'ggplot2':
      package 'ggplot2' was installed before R 4.0.0: please re-install it
      Ejecución interrumpida
      ---> Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException: Error del script R.
      Error: package or namespace load failed for 'ggplot2':
      package 'ggplot2' was installed before R 4.0.0: please re-install it
      Ejecución interrumpida

    • dpombal's avatar
      dpombal
      Post Partisan

      Problem is solved after DELETING old libraries inside

       

      "<user>/documents/R" and in "<user>/library"

       

       

      You can see in .libPaths 2 routes but....PowerBI also uses...  "C:\<user>/library"  ....remove old ones from here

      • "C:\<user>/documents/R"
      • C:\Program Files\R\R-4.0.2\library
      • webportal's avatar
        webportal
        Impactful Individual
        Actually, I had also tried that. I had conflicting versions of packages, and deleted all the old ones and reinstalled everything again to 4.0.2.
        It didn't work, so I uninstalled all 4.0.2 again, including R Gui and R Studio and reinstalled all 3.6.3. and it finally worked!
  • dpombal's avatar
    dpombal
    Post Partisan

    I have same issue, after updating R 3.5.3 to R 4.0.2

     

    2020-10-07T15:16:27.4697043Z

    Local Time:
    2020-10-07T17:16:27.4697043+02:00

    Session ID:
    e6c0803a-de48-4baa-95d2-15388843f4f0

    Release:
    August 2020

    Product Version:
    2.84.981.0 (20.08) (x64)

    Error Message:
    Error del script R.
    Error: package or namespace load failed for 'ggplot2':
    package 'ggplot2' was installed before R 4.0.0: please re-install it
    Ejecución interrumpida


    Stack Trace:
    Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: Error del script R.
    Error: package or namespace load failed for 'ggplot2':
    package 'ggplot2' was installed before R 4.0.0: please re-install it
    Ejecución interrumpida
    ---> Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException: Error del script R.
    Error: package or namespace load failed for 'ggplot2':
    package 'ggplot2' was installed before R 4.0.0: please re-install it
    Ejecución interrumpida

  • DanMandle's avatar
    DanMandle
    Frequent Visitor

    Have folks discovered other workarounds to the error? It's a bummer to have to remove old instances of R to get ggplot2 to work in Power BI. Particularly since there are some visualizations in PBI that only work on some of the older instances, and some on the newer instances. 

    • peterhui50's avatar
      peterhui50
      Helper III

      I just changed it to my old version and it worked.