Introduction :

This serves as a quick guide to get R scripts running in PowerBI

Step 1 - Install R

R can be installed from the following link : https://cran.r-project.org/bin/windows/base/ .Remember where you installed it.

Step 2 - Setup R in PowerBI

Go to File -> Options and Setting -> Options

Select R scripting from the side menu and then input your install path. For the IDE I set mine to RStudio. For RStudio install instructions See

https://www.datacamp.com/community/tutorials/installing-R-windows-mac-ubuntu?utm_source=adwords_ppc&utm_campaignid=898687156&utm_adgroupid=48947256715&utm_device=c&utm_keyword=&utm_matchtype=b&utm_network=g&utm_adpostion=&utm_creative=229765585183&utm_targetid=dsa-429603003980&utm_loc_interest_ms=&utm_loc_physical_ms=1000149&gclid=Cj0KCQjwtZH7BRDzARIsAGjbK2YH3kiq7Fy3bc9cS001_3hbuutZ_e00QOKK2pYwJLHuzjMKAWC96oEaAhpQEALw_wcB

Under visualisations you should now see the R icon.

Once the R icon is selected we can start dragging fields from our data set.

Note we now have an R script editor window. We can optionally type our code into. Observe the un-editable code put in by PowerBI to remove duplicate rows. This can cause issues if you don’t have an index column for obvious reasons.

Make sure your index column is set to not summarise. This will prevent PowerBI from summing it in the data set.

I would highly recommend writing your code in R Studio by the selecting edit script in external IDE.

PowerBI creates an REditorWrapper script with the data set ready to load. You can now write your code and take avantage of the benefits of writing in an IDE.

Once Finished and tested in RStudio, paste your code back into PowerBI and run

Some Limitations

*R visuals support is limited to the packages identified in Learn which R packages are supported. There currently is no support for custom packages.

*Data size limitations – data used by the R visual for plotting is limited to 150,000 rows. If more than 150,000 rows are selected, only the top 150,000 rows are used and a message is displayed on the image. Additionally, the input data has a limit of 250 MB.

*Resolution - all R visuals are displayed at 72 DPI.

*Plotting device - only plotting to the default device is supported.

*Calculation time limitation – if an R visual calculation exceeds 60 seconds the script times out, resulting in an error.

*R visuals are refreshed upon data updates, filtering, and highlighting. However, the image itself is not interactive and does not support tool tips.

*R visuals respond to highlighting other visuals, but you cannot click on elements in the R visual in order to cross filter other elements.

*R visuals are currently not supported for the Time data type. Please use Date/Time instead.

*R visuals do not display when using Publish to web.

*R visuals do not support renaming input columns. Columns will be referred to by their original name during script execution.

*R visuals currently do not print with dashboard and reports printing

*R visuals are currently not supported in the DirectQuery mode of Analysis Services