BLOG

How to create an R Script

24-02-2019  0 Comment(s)

We first need to write the R script before we import it into Power BI. Power BI only gives a minimal scripting area so it is much more easier to use an IDE to development the script. If you don’t have R setup on your computer then please read How to Setup Power BI to Use R Scripts. Open R Studio and create a new R file. In this article we are going to use the tidyquant package. Tidyquant downloads and analyzes financial data from publicly traded companies. We need to first download and install the “tidyquant” package. If you are sharing the desktop file then you need to include a function that checks to see if the R package is installed and if it isn’t then install it.  Please see the code below:

is.installed <- function(mypkg){

is.element(mypkg, installed.packages()[,1])

}

 

# check if package "tidyquant" is installed

if (!is.installed("tidyquant")){

install.packages("tidyquant")

}

 

require("tidyquant")

Now that we have the package installed, we can use it to query data. The code snippet below demonstrates how to retrieve pricing data and return the data to a data frame. Power BI recognizes data frames as individual tables.

 

 

Comment Here

Comments

No Comments to Show

WE ALWAYS WORK WITH :