Ahmad Fattahi

Using PI with R and RExcel

Blog Post created by Ahmad Fattahi Employee on Oct 19, 2010

R is an open source programming language and software environment specialized in statistical analysis, programming, and graphics. It provides lots of powerful analytical tools for statistical purposes. We, the PI professionals, deal with huge amounts of data on a constant basis. Therefore, it seems like a natural quest to have some statistical tool for analyzing and extracting statistically valuable information from data stored in PI.


This post is a first attempt to get us all familiarized with R and how we can link that with PI data. To keep things simple we use an add-in to Microsoft Excel called RExcel that brings in R capabilities inside Microsoft Excel. From that point on we use PI DataLink to bring in PI data and perform our statistical operations on them using RExcel. Later on we will see other ways to connect PI with R.


What you would need to do is to download and install R and RExcel. You can access the documentation here. Then you can use the Excel sheet attached to this post. The only change you need to do is pointing PI DataLink to your PI server as opposed to mine in the “Values” column. It is made as a self-explanatory first step on how you can perform some basic statistical operations on PI data (obviously you need PI DataLink to bring in PI data).


The operations include mean value, variance, linear regression, and regression analysis along with some plotting of the regression. Some of these features may be possible through MS Excel itself; however, once we know how to use R we will see that the features will surpass MS Excel pretty fast. You are all set and ready to go; good luck and have fun!