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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

0

Custom R Visual - Tidyr "spread" function not found

Error Message 1:

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.

 

Error Message 2:

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.

 

Question:

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

Status: Delivered
Comments
v-chuncz-msft
Community Support
Status changed to: Investigating
 
v-chuncz-msft
Community Support

@negodfre 

 

You may check R packages that are supported in Power BI and share a sample to reproduce the issue if possible.

negodfre
Regular Visitor

I solved the issue.

 

I was using a .libPaths()[3] to point to the location where my libraries were installed, but this didn't work in powerbi.com. It appeared to default to the C:/users/program files location. I changed the path per this article:

Power BI: R Home Directory vs Library Trees – Data Inspirations

 

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. Then pointed powerbi to the new location with the R.exe.

v-chuncz-msft
Community Support
Status changed to: Delivered