Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

R script as data source in Power BI Desktop

I want to use an R  script to connects to an API, and extract data into a data frame.  The script is executing in R studio but I get the follwing error in power BI desk top.

Details: "Exception of type 'Microsoft.Analytics.Modules.R.ErrorHandling.RException.Primitives.NotValidRDataException' was thrown."

 

I created a very simple script just to test the R script as a data source and I get the same error.  

steps to reproduce

1. start power bi desk top

2. get data > R script > click connect

3. In the  R Script dialog enter df <- c(1,2,3). 

4. click o.k. 

Result:

Unable to Connect

We encountered an error while trying to connect. 

Details: "Exception of type 'Microsoft.Analytics.Modules.R.ErrorHandling.RException.Primitives.NotValidRDataException' was thrown."

 

The script editor shows the script will run with the following R installation c:\program files\R\R-3.6.0.

  • Anonymous's avatar
    Anonymous
    7 years ago

    Thank you for the reply.  The problem was with R version R-3.6.0. 

     

    Here is the fix. File > Options and Settings > R scripting > select a lower version of R e.g. C:\Program Files\R\R-3.5.0

     

    I can now process the results of the API call in R and connect the script to Power BI as a data source. 

     

     

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for the reply.  The problem was with R version R-3.6.0. 

     

    Here is the fix. File > Options and Settings > R scripting > select a lower version of R e.g. C:\Program Files\R\R-3.5.0

     

    I can now process the results of the API call in R and connect the script to Power BI as a data source. 

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Just wanted to say thank you!! This worked for me as well.

    • DSmirnov's avatar
      DSmirnov
      New Member

      Many thanks, works for my R-4.0.2 installation with Power BI Desktop.

       
       
       
       
       
  • v-xicai's avatar
    v-xicai
    Community Support

    Hi Anonymous ,

     

    Based my test in Power BI Desktop, the R Scrip works fine for connect to data source using the code " iris_raw <- iris ".

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Please check if you have installed an R IDE on your local computer.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    You can learn more go through the links: https://www.red-gate.com/simple-talk/sql/bi/power-bi-introduction-working-with-r-scripts-in-power-bi-desktop-part-3/

                                                                             https://docs.microsoft.com/en-us/power-bi/desktop-r-ide

    Please understand that this link is provided “AS IS” with no warranties or guarantees of content changes, and confers no rights.

     

    Best Regards,

    Amy

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.