A couple of days ago...this blog Let R Embrace Data Visualization in HANA Studio gave me the power I need to keep working on this...but of course...life is not that beautiful so I still need to do lots of things in order to get this done...
First...cygwin didn't worked for me -:( so I used Xming instead -;)
Now...one thing that it's really important is to have all the X11 packages loaded into the R Server...so just do this...
Connect to your R Server via Putty and then type "yast" to enter the "Yet another setup tool". (Make sure you tick the X11 Forwarding)...
Search and install everything related to X11-Devel. Also install/update your Firefox browser (also on yast).
With that ready...we can keep going -;)
If you had R installed already...please delete it...as easy as this...
rm -r R-2.15.0
Then, download the source again...keep in mind that we will need R-2.15.1
Now...we need support for jpeg images...so let's download a couple of files...
When you run vi on the file you should comment out the bitmap.dll source directory lines just like in the image (notice that I'm not dealing with TIFF images, as they didn't worked for me)...
Now, we need to into each folder and compile the libraries...
When both libraries finished compiling...we can go an compile R -;)
As you can see...where using the parameter --with-x=yes to indicate that we want to have X11 into our R installation. As we compiled the JPEG and PNG libraries first...we will have support for this on R as well -;)
For sure...this will take a while...R compilation is a hard task -:P But in the end you should be able to confirm by doing this...
Now...it's time to install Shiny -8)
Easy as cake -:)
But here comes another tricky part...we need to create a new user...why? Because we mostly had a previous user to run the Rserve...that was created before we installed X11...so just create a new one -:)
useradd -m login_name
For the X11 to work perfectly...we need to do another thing...
This will return us a line that we should copy in a notepad...then...we need to log of and log in again via Putty (with the X11 Forwarding) but this time using our new user...the second line will tell us about the display, so copy that one as well...
Once logged with the new user...do this...
xauth add //Magic_Cookie_from_Notepad//
Now...we're are complete ready to go...
Start the Rserve server like this...
R CMD Rserve --RS-port 6311 --no-save --RS-encoding "utf8"
When our Rserve is up and running...it's time for SAP HANA to make it's entrance -;) What I really like about Shiny...is that...in the past you needed to create two files to make it work UI.R and Server.R...right now...Shiny uses the Bootstrap framework so we can create the webpage using just one file...or call it directly from the SAP HANA Studio -;)
CREATE TYPE SNVOICE AS TABLE(
I'm not going to explain the code, because you should learn some R and Shiny -:P But if you wonder why I have a "dummy" table...it's mainly because you can't create an Stored Procedure in R Lang that doesn't have an OUT parameter...so...does nothing but helps to run the code :)
When we call the script or the procedure Call_Shiny, the X11 from our Server is going to call Firefox which is going to appear on our desktop like this...
We can choose between 2010, 2011 and 2012...every time we choose a new value, the graphic will be automatically updated...
Before we finish...keep in mind that this approach is really slow...our R Server will send the information via X11 Forwarding to our machine, and will render the Firefox browser...also...we have a timer...so after so many seconds...we will have a Timeout...of course this can be configured, but for Performance purposes...we should limit the time the communication between our SAP HANA and R servers...
Hope you like this blog -:) and see you on the next one -;)