Search code examples
rpowerbitidyr

Why is R library not loading in app.powerbi.com?


I keep getting the following error on app.powerbi.com:

"Error in pivot_wider(data, names_from=names,values_from=values): could not find function "pivot_wider""

I load the 'tidyr' package as a required library. I get the same error when using "spread" instead of pivot_wider.

When I specify the function using:

tidyr::pivot_wider(data, names_from=names, values_from=values)

I get a different error: "Error in loadNamespace(name): there is no package called 'tidyr'".

PowerBI Desktop everything works perfectly fine. It's only on the published PowerBI report that I get the error.

What can I do to resolve this issue? Alternative library / function to 'pivot_wider' or 'spread'?


Solution

  • I was able to verify using print statements that the report on powerbi.com was not able to access the r packages that were installed.

    I was using a .libPaths()[3] to point to the location where my libraries were installed, but this didn't work in powerbi.com.

    I ended up re-installing R to a location where I could install packages to, since admin rights are necessary to write to the C:/users/program files location.