This tutorial shows how to use R-script to define data for Power BI Desktop. (This article describes use of R-script for Power BI publishing).

Before start, make sure you installed R.

Then go to Power BI Desktop and click on Get data / All / R script.

Then write some script resulting in Data Frame.

 

my_names = c("Anna", "Britta", "Anna", "Lasse", "Bosse", "Olle")
my_ages = c(6,5,7,6,7,5)
my_table = data.frame(my_names, my_ages)

After confirmation table is loaded:

Or we can write some script containing connection to external source (for example to .csv). Practically, you will probably use it when some R-modification are needed – otherwise you can connect to .csv directly…

It can be something like this:

setwd("C:/Users/beran/Desktop/Rzdroje")
cars = read.csv2("cars.csv")

Again, it results in a normal table, showing table from source. 

Leave a Reply

Your email address will not be published.

*

clear formPost comment