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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

R Source and Scripts in Power Query do not work for R version 3.6.0

I have been using R scripts in my PowerBI Desktop Power Queries for over a year, but after updating to the latest version of R, 3.6.0 (Current CRAN version) the queries fail with the following error: Details: "Exception of type 'Microsoft.Analytics.Modules.R.ErrorHandling.RException.Primitives.NotValidRDataException' was thrown."

 

This occurs for my existing R scripts as well as really simple new ones. (such as the following: = R.Execute("output <- data.frame(test = 7)"))

 

Based on searching, I believe other people are also experiencing the same issue. Here is a thread discussing it, but I could not find an issue referring to it.

https://community.powerbi.com/t5/Desktop/Connecting-to-R-dataset-unable-to-connect/td-p/680953

The error seems to not occur if I use the options menu to switch the version of R used by Power BI back to 3.5.1 although others said otherwise.

 

Here is the change in R 3.6.0 I think is most likely to cause the this issue: 

R change: 

Serialization format version 3 becomes the default for
      serialization and saving of the workspace (save(), serialize(),
      saveRDS(), compiler::cmpfile()).  Serialized data in format 3
      cannot be read by versions of R prior to version 3.5.0.
      Serialization format version 2 is still supported and can be
      selected by version = 2 in the save/serialization functions.  The
      default can be changed back for the whole R session by setting
      environment variables R_DEFAULT_SAVE_VERSION and
      R_DEFAULT_SERIALIZE_VERSION to 2.  For maximal
      back-compatibility, files vignette.rds and partial.rdb generated
      by R CMD build are in serialization format version 2, and resave
      by default produces files in serialization format version 2
      (unless the original is already in format version 3).

 

Status: Accepted
Comments
v-qiuyu-msft
Community Support

Hi @MarkRwPBI

 

I have reported this issue internally: CRI 119558694. Will update here once I get any information. 

 

Best Regards,
Qiuyun Yu 

v-qiuyu-msft
Community Support
Status changed to: Accepted
 
midlvlmgmt
Regular Visitor

Any update to this problem?

v-qiuyu-msft
Community Support

Hi all, 

 

I got information below from PG team: 

 

"Using R 3.6.0 is not yet supported in Power BI Desktop. We are updating the documentation here: https://docs.microsoft.com/en-us/power-bi/service-r-packages-support#r-scripts-that-are-not-supporte..."

 

Best Regards,
Qiuyun Yu 

Anonymous
Not applicable

Do you have some information about it? It is still not possible to add R3.6 as a data source. 

Anonymous
Not applicable

Still no fix?

 

As @MarkRwPBI suspected, the issue apparently lies in the change to the way the data is serialized in R.

Fortunately, as stated also in the changelog, you can force the serialization to the old style.

 

I got my scripts working after I put this line as the first line of the script:

Sys.setenv(R_DEFAULT_SERIALIZE_VERSION="2", R_DEFAULT_SAVE_VERSION="2")

 

Thus, no more need to have R-3.5.3 installed.