Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Using the Statistical Program R for Running Statistics


Using the Statistical Program R for Running Statistics

Author
Message
Tomaz Kastrun
Tomaz Kastrun
SSC-Enthusiastic
SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)SSC-Enthusiastic (152 reputation)

Group: General Forum Members
Points: 152 Visits: 753
Comments posted to this topic are about the item Using the Statistical Program R for Running Statistics

Tomaž Kaštrun | twitter: @tomaz_tsql | blog: https://tomaztsql.wordpress.com/
stefan.lipiec
stefan.lipiec
SSC Veteran
SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)SSC Veteran (293 reputation)

Group: General Forum Members
Points: 293 Visits: 274
I have only scanned the article briefly and I would like say that please check the security implications of enabling xp_cmdshell with whoever is responsible for the the security of your IT department, it is a very powerful command and a lot of people won't want it enabled.

Regards,

Stefan.
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19853 Visits: 13251
Nice article. Very useful for data profiling, amongst other things.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Steph Locke
Steph Locke
SSC Veteran
SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)SSC Veteran (231 reputation)

Group: General Forum Members
Points: 231 Visits: 870
Great article Tomaz!

I've been doing a lot of work with R and I knew that theoretically it was possible to embed R in SQLServer but I had no clue how to. I'll be adding a link to this article on my intro to R - great resource, thanks :-)
rp-sqlsc
rp-sqlsc
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 543
We had looked for some similar way to do this and ended up implementing a R service running in a polling loop (2 sec delay) reading requests from a SQL table, executing the script in the request, and returning the output via another table.

In addition, our implementation allows multiple R services on multiple systems to process requests from multiple SQL Server tasks (if we needed to do so.)

We were a bit concerned about shelling out to a command prompt (security and performance). Still it is good to have this nicely detailed set of instructions.

-----

I also wanted to add that it seems very strange that R cannot be run within SQL Server due to incompatibilities with the embedded .NET libraries and the open source rserve program. PostgreSQL has a very nice way to call R from within a user function. I may sound uncharitable but I wonder if this isn't on purpose to encourage Windows users to use SSAS....
Stan Kulp-439977
Stan Kulp-439977
SSC-Addicted
SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)

Group: General Forum Members
Points: 422 Visits: 1107
Great article. Thanks for writing it.
Eirikur Eiriksson
Eirikur Eiriksson
SSCrazy Eights
SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)

Group: General Forum Members
Points: 8988 Visits: 18233
Thank you Tomaz for this article.

stefan.lipiec (3/10/2014)
I have only scanned the article briefly and I would like say that please check the security implications of enabling xp_cmdshell with whoever is responsible for the the security of your IT department, it is a very powerful command and a lot of people won't want it enabled.

Regards,

Stefan.




For this reason, I limit the usage to desktop R and ODBC R/W connections to the Database servers.

Cool
wallace.dave
wallace.dave
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 103
How do you limit the usage?
Eirikur Eiriksson
Eirikur Eiriksson
SSCrazy Eights
SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)SSCrazy Eights (9K reputation)

Group: General Forum Members
Points: 8988 Visits: 18233
wallace.dave (3/10/2014)
How do you limit the usage?


Hi,
the usage would be restricted to running R from a desktop using ODBC connections and Windows authentication. The users can access the same data using R as SSMS.

EE Whistling
RobertYoung
RobertYoung
SSC-Enthusiastic
SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)

Group: General Forum Members
Points: 110 Visits: 232
PostgreSQL has a very nice way to call R from within a user function. I may sound uncharitable but I wonder if this isn't on purpose to encourage Windows users to use SSAS....


I've used PL/R, and most of the other industrial strength (i.e. commercial) databases manage to embed access to R at the engine level. With PG + PL/R it's accomplished because PG supports used defined functions using C/C++, and PL/R actually is in C, so while the language attribute is "R", it's really C.

One of the MS sites says this, however:
"CLR functions can be used to access native (unmanaged) code, such as code written in C or C++, via the use of PInvoke from managed code"

So, one could write a PL/R style hook for SQL Server?? Seems odd that no one has. (The same applies to DB2, by the way.) The "you can't touch Open Source without giving away *your* program" baloney hasn't stopped Oracle or SAP.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search