Reference: https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals
Notes for setup:
- In PowerBI: File -> Options and Settings -> Options -> R scripting
- The libraries required to run R visuals in PowerBI needs to be installed in the R library. The R codes in PowerBI can’t process install.packages(” “) function.
- Go to c:\program Files\R\R-x.x.x\library folder to check if you already have the required R package installed.
- In the Options for “R scripting”, click “Change temporary storage location” to point to c:\program Files\R\R-x.x.x\library folder.
Note for the PowerBI and R Integration Example:
- Use “Get Data” to get raw dataset into PoweBI, then the variables will show up in the “Fields” panel.
- Click “R” in the “Visualizations” panel, then a grey visual placeholder will show up in the body section of the page and the “R script editor” will show up at the bottom of the page.
- Drag or select variables in the “Fields” panel, the variables will be added to the “Values” section on the “Visualizations” panel, and the variables will be automatically incorporated in a dataframe called “dataset”. You don’t need to do additional code to create the dataframe, and don’t remove the “#” sign from line 1 to line 7 of the code.
- Starting on line 7, create your own r script.
- Start with require(” “) and library() to attached the required packaged for this R visual.
- Filters are interactive with the R visual.
- Multiple R visuals can be created on the same page and each visual has its own R codes.