SlideShare a Scribd company logo
1 of 27
Download to read offline
R & EXT. WORD
RESEARCH=>DEVELOPMENT
Ruslan Shevchenko
email: ruslan@shevchenko.kiev.ua
twitter: @rssh1
github: https://github.com/rssh
work: Lynx Capital Partners [consultant]
R & EXT. WORLD : TALK OVERIEW
Let we build some model in R.
(Rewrite/Embed/R for all)
Integration techniques.
cmdline [littler, Rscript]
Language-level integration [RInside/Rcpp, RScala, rpy ]
R as net service [rApache, openCPU, Shiny ]
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
2. Integrate R code with business logic ?
3. Implement business logic in R ?
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
1. Additional time and money
2. Improvements will follow long path.
=> Only if absolute necessary.
(platform, performance, etc ….)
2. Integrate R code with business logic in other language
3. Implement business logic in R ?
4. Migrate to other ecosystems ?
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
2. Integrate R code with business logic in other language ?
1. Complex.
2. Extra maintenance cost.
3. Implement business logic in R ?
4. Migrate to other ecosystems ?
=> Only if we have no other way
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
2. Integrate R code with business logic in other language ?
3. Implement business logic in R ?
1. Esoteric way.
2. R was created without ‘software engineering’ way of
thinking ‘in mind’.
4. Migrate to other ecosystems ?
python
R
Experience
Productivity
Warn: Speculative !!!
(based on filling)
=> Only if R is ideal fit.
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
2. Integrate R code with business logic in other language ?
3. Implement business logic in R ?
4. Migrate to other ecosystems ? => No clear superior
Now: Python, Octave/Matlab
Future: Scalalab (?)
Julia (?)
//! statistics //! fully compatible/free
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
2. Integrate R code with business logic ?
3. Implement business logic in R ?
LET WE BUILD SOME MODEL IN R.
WHAT NEXT ?
1. Rewrite in ‘real’ programming language for real usage ?
2. Integrate R code with business logic in other language ?
3. Implement business logic in R ?
R INTEGRATIONS
(Old S): 1976, New S: 1988, S4: 1996
R: 1995
1-st integrations:
littler: 2006
Rscript: 2006 (in R installation)
Only interactive
COMMAND LINE
littler (#!/<path>/r … )
ls -la | awk '{print $5}' | littler -e ‘print(summary(as.integer(readLines())))’
echo 'cat(rnorm(10))' | littler
Rscript (#!/<path>/Rscript … )
ls -la | awk '{print $5}' | Rscript -e “summary(as.numeric(readLines('stdin')))"
'cat(rnorm(10))' | Rscript -
LIBRARY LEVEL
Embedding in R (C library loaded as R extension)
R extensions. [Cpp as scripting language, etc]
Start something like littler as separate process
Actually used instead R Embedding.
(reasons: Organization of R-interpreter .. )
CALL PROCESS/USE FROM R
C++ : RInside (R from C++)/ (RCPP: C++ inside R)
#include <RInside.h>
int main(int argc, char *argv[]) {
RInside R(argc, argv);
R["txt"] = "Hello, world!n";
R.parseEvalQ("cat(txt)");
exit(0);
}
R instance started
// [[Rcpp::export]]
double parallelVectorSum(NumericVector x) {
// declare the SumBody instance
Sum sum(x);
// call parallel_reduce to start the work
parallelReduce(0, x.length(), sum);
// return the computed sum
return sum.value;
}
CALL PROCESS/USE FROM R
C++
RInside (R from C++)/ (RCPP: C++ inside R)
Java/Scala
JVMRI | rScala / rJava
Python:
rpy2 / rpython
Yet one approach: // FastR: R implementation in Java
NETWORK[WEB]
Low level: rApache / httpuv
rApache: http://rapache.org : R calls from apache
module.
httpuv: https://github.com/rstudio/httpuv/ : web
server inside R
Usually httpuv used for development, rApache - for
serving in production.
R & WEB
High-Level:
API: openCPU (http://www.opencpu.org)
Applications:
shiny: http://www.rstudio.com/products/Shiny/
Rook + dashboard (CPAN)
Interactive r from web: RStudio Server
OPENCPU
install.packages(‘opencpu’)
library(‘opencpu’) Start web server
http://localhost:2347/ocpu
Browse any data
Call any function
• GET:
• http://<base>/library/datasets/data/cars/json
• cars dataset in json
• http://<base>/library/stats/info
• info about stats package
• http://<base>/library/stats/R/glm/print
• R source for glm
OPENCPU POST: DEMO
POST
• URL: http://<base>/library/stats/R/rnorm
• Params: n=10
POST
• URL: http://<base>/library/stats/R/rnorm?json
• Params: n=10
• Result: [-0.315, 0.6241, 0.7175, 1.1813,
-2.5993, -0.9768, -0.034, 0.503,
-0.4165, 1.0353]
Id of object in R environment
OPENCPU POST: DEMO
POST
• URL: http://<base>/library/graphics/R/plot
• Params: x=x075fecda05 (key of object received in plot)
http://<base>/tmp/x01ccbd847f/graphics/1/png
opencpu.js — support library
OPENCPU
Input/Output format can be set in URL.
Data: JSON, CSV, TAB, Protobuf, RDA, …
Graphics: PNG, SVG, PDF
Texts: plain, markdown,
OPENCPU
Web application is R package
(i.e. simple archive with R code and html landing page)
openCPU-server for production. (using rApache )
Exists openCPU PAAS.
Packages which published on github are loaded
automatically
On you local server you can do the same with own repo
OPENCPU
Natural way to publish R API
Ideal as ‘R Microservice’.
Caveats:
authorization must be implemented separately
load-balancing must route same sessions to the
same servers.
SHINY
Present data from R
http://shiny.rstudio.com/
DSL for HTML UI Elements
Reactive connection with R over web sockets.
// demonstration: movie database
BATCH PROCESSING
Triggering Mail, SOAP, file upload, etc.
RSB: R Servise Bus:
http://www.openanalytics.eu/
https://github.com/openanalytics/RSB
Revolution: R on Azure
SparkR (now merged into Spark): R on spark.
WHEN TO STOP
When to stop and migrate to other solutions ?
complex integration (more than <K> calls )
hight maintenance cost of hybrid solution.
(rare)
performance loss is issue.
R & EXT. WORLD.
It is possible to use ‘R’ as element of application
infrastructure in combination with ‘software-
engineering languages’.
Fast [Research => Deploy] loops is important.
THANKS.
QUESTIONS ?
Ruslan Shevchenko: <ruslan@shevchenko.kiev.ua>
https://github.com/rssh

More Related Content

What's hot

Return-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code InjectionReturn-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code Injection
guest9f4856
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
tutorialsruby
 
使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架
jeffz
 

What's hot (20)

Triton and symbolic execution on gdb
Triton and symbolic execution on gdbTriton and symbolic execution on gdb
Triton and symbolic execution on gdb
 
Return-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code InjectionReturn-Oriented Programming: Exploits Without Code Injection
Return-Oriented Programming: Exploits Without Code Injection
 
Implementing a JavaScript Engine
Implementing a JavaScript EngineImplementing a JavaScript Engine
Implementing a JavaScript Engine
 
Introduction to Khronos SYCL
Introduction to Khronos SYCLIntroduction to Khronos SYCL
Introduction to Khronos SYCL
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Gate of Agile Web Development
Gate of Agile Web DevelopmentGate of Agile Web Development
Gate of Agile Web Development
 
effective_r27
effective_r27effective_r27
effective_r27
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented Programmers
 
Android antipatterns
Android antipatternsAndroid antipatterns
Android antipatterns
 
Should i Go there
Should i Go thereShould i Go there
Should i Go there
 
Kubernetes Internals
Kubernetes InternalsKubernetes Internals
Kubernetes Internals
 
parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架
 
Going FaaSter, Functions as a Service at Netflix
Going FaaSter, Functions as a Service at NetflixGoing FaaSter, Functions as a Service at Netflix
Going FaaSter, Functions as a Service at Netflix
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Klee and angr
Klee and angrKlee and angr
Klee and angr
 
TypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without AnnotationsTypeProf for IDE: Enrich Development Experience without Annotations
TypeProf for IDE: Enrich Development Experience without Annotations
 
Preview of Terraform 0.12 + modules.tf - Kiev HUG meetup
Preview of Terraform 0.12 + modules.tf - Kiev HUG meetupPreview of Terraform 0.12 + modules.tf - Kiev HUG meetup
Preview of Terraform 0.12 + modules.tf - Kiev HUG meetup
 
Take Flight - Using Fly with the Play Framework
Take Flight - Using Fly with the Play FrameworkTake Flight - Using Fly with the Play Framework
Take Flight - Using Fly with the Play Framework
 
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
 

Similar to R ext world/ useR! Kiev

Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...
Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...
Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...
Revolution Analytics
 

Similar to R ext world/ useR! Kiev (20)

Introduction to R and R Studio
Introduction to R and R StudioIntroduction to R and R Studio
Introduction to R and R Studio
 
R as supporting tool for analytics and simulation
R as supporting tool for analytics and simulationR as supporting tool for analytics and simulation
R as supporting tool for analytics and simulation
 
Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...
Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...
Introducing Revolution R Open: Enhanced, Open Source R distribution from Revo...
 
Rcpp
RcppRcpp
Rcpp
 
Integrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBufIntegrating R with C++: Rcpp, RInside and RProtoBuf
Integrating R with C++: Rcpp, RInside and RProtoBuf
 
1 R Tutorial Introduction
1 R Tutorial Introduction1 R Tutorial Introduction
1 R Tutorial Introduction
 
R programming
R programmingR programming
R programming
 
Apache Jena Elephas and Friends
Apache Jena Elephas and FriendsApache Jena Elephas and Friends
Apache Jena Elephas and Friends
 
Tableau integration with R
Tableau integration with RTableau integration with R
Tableau integration with R
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by...
 
R programming
R programmingR programming
R programming
 
PHP is the king, nodejs is the prince and Python is the fool - Alessandro Cin...
PHP is the king, nodejs is the prince and Python is the fool - Alessandro Cin...PHP is the king, nodejs is the prince and Python is the fool - Alessandro Cin...
PHP is the king, nodejs is the prince and Python is the fool - Alessandro Cin...
 
PHP is the King, nodejs the prince and python the fool
PHP is the King, nodejs the prince and python the foolPHP is the King, nodejs the prince and python the fool
PHP is the King, nodejs the prince and python the fool
 
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
An OpenShift Primer for Developers to get your Code into the Cloud (PTJUG)
 
Pyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdfPyhton-1a-Basics.pdf
Pyhton-1a-Basics.pdf
 
R Programming Overview
R Programming Overview R Programming Overview
R Programming Overview
 
Christian Mladenov @ Intuitics
Christian Mladenov @ IntuiticsChristian Mladenov @ Intuitics
Christian Mladenov @ Intuitics
 
APIdays 2015 - The State of Web API Languages
APIdays 2015 - The State of Web API LanguagesAPIdays 2015 - The State of Web API Languages
APIdays 2015 - The State of Web API Languages
 
APIdays 2015 - The State of Web API Languages
APIdays 2015 - The State of Web API LanguagesAPIdays 2015 - The State of Web API Languages
APIdays 2015 - The State of Web API Languages
 

More from Ruslan Shevchenko

Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
Ruslan Shevchenko
 

More from Ruslan Shevchenko (20)

Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]Embedding Generic Monadic Transformer into Scala. [Tfp2022]
Embedding Generic Monadic Transformer into Scala. [Tfp2022]
 
Svitla talks 2021_03_25
Svitla talks 2021_03_25Svitla talks 2021_03_25
Svitla talks 2021_03_25
 
Akka / Lts behavior
Akka / Lts behaviorAkka / Lts behavior
Akka / Lts behavior
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
 
Scala / Technology evolution
Scala  / Technology evolutionScala  / Technology evolution
Scala / Technology evolution
 
{co/contr} variance from LSP
{co/contr} variance  from LSP{co/contr} variance  from LSP
{co/contr} variance from LSP
 
N flavors of streaming
N flavors of streamingN flavors of streaming
N flavors of streaming
 
SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.SE 20016 - programming languages landscape.
SE 20016 - programming languages landscape.
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Java & low latency applications
Java & low latency applicationsJava & low latency applications
Java & low latency applications
 
IDLs
IDLsIDLs
IDLs
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
 
Behind OOD: domain modelling in post-OO world.
Behind OOD:  domain modelling in post-OO world.Behind OOD:  domain modelling in post-OO world.
Behind OOD: domain modelling in post-OO world.
 
scala-gopher: async implementation of CSP for scala
scala-gopher:  async implementation of CSP  for  scalascala-gopher:  async implementation of CSP  for  scala
scala-gopher: async implementation of CSP for scala
 
Programming Languages: some news for the last N years
Programming Languages: some news for the last N yearsProgramming Languages: some news for the last N years
Programming Languages: some news for the last N years
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
 
Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014Ruslan.shevchenko: most functional-day-kiev 2014
Ruslan.shevchenko: most functional-day-kiev 2014
 
Web architecture - overview of techniques.
Web architecture - overview of  techniques.Web architecture - overview of  techniques.
Web architecture - overview of techniques.
 
R scala 17_05_2014
R scala 17_05_2014R scala 17_05_2014
R scala 17_05_2014
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Recently uploaded (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

R ext world/ useR! Kiev

  • 1. R & EXT. WORD RESEARCH=>DEVELOPMENT Ruslan Shevchenko email: ruslan@shevchenko.kiev.ua twitter: @rssh1 github: https://github.com/rssh work: Lynx Capital Partners [consultant]
  • 2. R & EXT. WORLD : TALK OVERIEW Let we build some model in R. (Rewrite/Embed/R for all) Integration techniques. cmdline [littler, Rscript] Language-level integration [RInside/Rcpp, RScala, rpy ] R as net service [rApache, openCPU, Shiny ]
  • 3. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 2. Integrate R code with business logic ? 3. Implement business logic in R ?
  • 4. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 1. Additional time and money 2. Improvements will follow long path. => Only if absolute necessary. (platform, performance, etc ….) 2. Integrate R code with business logic in other language 3. Implement business logic in R ? 4. Migrate to other ecosystems ?
  • 5. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 2. Integrate R code with business logic in other language ? 1. Complex. 2. Extra maintenance cost. 3. Implement business logic in R ? 4. Migrate to other ecosystems ? => Only if we have no other way
  • 6. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 2. Integrate R code with business logic in other language ? 3. Implement business logic in R ? 1. Esoteric way. 2. R was created without ‘software engineering’ way of thinking ‘in mind’. 4. Migrate to other ecosystems ? python R Experience Productivity Warn: Speculative !!! (based on filling) => Only if R is ideal fit.
  • 7. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 2. Integrate R code with business logic in other language ? 3. Implement business logic in R ? 4. Migrate to other ecosystems ? => No clear superior Now: Python, Octave/Matlab Future: Scalalab (?) Julia (?) //! statistics //! fully compatible/free
  • 8. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 2. Integrate R code with business logic ? 3. Implement business logic in R ?
  • 9. LET WE BUILD SOME MODEL IN R. WHAT NEXT ? 1. Rewrite in ‘real’ programming language for real usage ? 2. Integrate R code with business logic in other language ? 3. Implement business logic in R ?
  • 10. R INTEGRATIONS (Old S): 1976, New S: 1988, S4: 1996 R: 1995 1-st integrations: littler: 2006 Rscript: 2006 (in R installation) Only interactive
  • 11. COMMAND LINE littler (#!/<path>/r … ) ls -la | awk '{print $5}' | littler -e ‘print(summary(as.integer(readLines())))’ echo 'cat(rnorm(10))' | littler Rscript (#!/<path>/Rscript … ) ls -la | awk '{print $5}' | Rscript -e “summary(as.numeric(readLines('stdin')))" 'cat(rnorm(10))' | Rscript -
  • 12. LIBRARY LEVEL Embedding in R (C library loaded as R extension) R extensions. [Cpp as scripting language, etc] Start something like littler as separate process Actually used instead R Embedding. (reasons: Organization of R-interpreter .. )
  • 13. CALL PROCESS/USE FROM R C++ : RInside (R from C++)/ (RCPP: C++ inside R) #include <RInside.h> int main(int argc, char *argv[]) { RInside R(argc, argv); R["txt"] = "Hello, world!n"; R.parseEvalQ("cat(txt)"); exit(0); } R instance started // [[Rcpp::export]] double parallelVectorSum(NumericVector x) { // declare the SumBody instance Sum sum(x); // call parallel_reduce to start the work parallelReduce(0, x.length(), sum); // return the computed sum return sum.value; }
  • 14. CALL PROCESS/USE FROM R C++ RInside (R from C++)/ (RCPP: C++ inside R) Java/Scala JVMRI | rScala / rJava Python: rpy2 / rpython Yet one approach: // FastR: R implementation in Java
  • 15. NETWORK[WEB] Low level: rApache / httpuv rApache: http://rapache.org : R calls from apache module. httpuv: https://github.com/rstudio/httpuv/ : web server inside R Usually httpuv used for development, rApache - for serving in production.
  • 16. R & WEB High-Level: API: openCPU (http://www.opencpu.org) Applications: shiny: http://www.rstudio.com/products/Shiny/ Rook + dashboard (CPAN) Interactive r from web: RStudio Server
  • 17. OPENCPU install.packages(‘opencpu’) library(‘opencpu’) Start web server http://localhost:2347/ocpu Browse any data Call any function • GET: • http://<base>/library/datasets/data/cars/json • cars dataset in json • http://<base>/library/stats/info • info about stats package • http://<base>/library/stats/R/glm/print • R source for glm
  • 18. OPENCPU POST: DEMO POST • URL: http://<base>/library/stats/R/rnorm • Params: n=10 POST • URL: http://<base>/library/stats/R/rnorm?json • Params: n=10 • Result: [-0.315, 0.6241, 0.7175, 1.1813, -2.5993, -0.9768, -0.034, 0.503, -0.4165, 1.0353] Id of object in R environment
  • 19. OPENCPU POST: DEMO POST • URL: http://<base>/library/graphics/R/plot • Params: x=x075fecda05 (key of object received in plot) http://<base>/tmp/x01ccbd847f/graphics/1/png opencpu.js — support library
  • 20. OPENCPU Input/Output format can be set in URL. Data: JSON, CSV, TAB, Protobuf, RDA, … Graphics: PNG, SVG, PDF Texts: plain, markdown,
  • 21. OPENCPU Web application is R package (i.e. simple archive with R code and html landing page) openCPU-server for production. (using rApache ) Exists openCPU PAAS. Packages which published on github are loaded automatically On you local server you can do the same with own repo
  • 22. OPENCPU Natural way to publish R API Ideal as ‘R Microservice’. Caveats: authorization must be implemented separately load-balancing must route same sessions to the same servers.
  • 23. SHINY Present data from R http://shiny.rstudio.com/ DSL for HTML UI Elements Reactive connection with R over web sockets. // demonstration: movie database
  • 24. BATCH PROCESSING Triggering Mail, SOAP, file upload, etc. RSB: R Servise Bus: http://www.openanalytics.eu/ https://github.com/openanalytics/RSB Revolution: R on Azure SparkR (now merged into Spark): R on spark.
  • 25. WHEN TO STOP When to stop and migrate to other solutions ? complex integration (more than <K> calls ) hight maintenance cost of hybrid solution. (rare) performance loss is issue.
  • 26. R & EXT. WORLD. It is possible to use ‘R’ as element of application infrastructure in combination with ‘software- engineering languages’. Fast [Research => Deploy] loops is important.
  • 27. THANKS. QUESTIONS ? Ruslan Shevchenko: <ruslan@shevchenko.kiev.ua> https://github.com/rssh