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

PPTX
Dive into ROP - a quick introduction to Return Oriented Programming
PDF
Why scala is not my ideal language and what I can do with this
PDF
Csp scala wixmeetup2016
PDF
[COSCUP 2020] How to use llvm frontend library-libtooling
PDF
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
PDF
Experiments in Sharing Java VM Technology with CRuby
PDF
From V8 to Modern Compilers
PPTX
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)
Dive into ROP - a quick introduction to Return Oriented Programming
Why scala is not my ideal language and what I can do with this
Csp scala wixmeetup2016
[COSCUP 2020] How to use llvm frontend library-libtooling
Scala-Gopher: CSP-style programming techniques with idiomatic Scala.
Experiments in Sharing Java VM Technology with CRuby
From V8 to Modern Compilers
Running Ruby on Solaris (RubyKaigi 2015, 12/Dec/2015)

What's hot (20)

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

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

PDF
Python and R for quantitative finance
PDF
吳齊軒/漫談 R 的學習挑戰與 R 語言翻轉教室
PDF
R Intro
PDF
Python vs. r for data science
PPTX
R_L1-Aug-2022.pptx
PPTX
R programming presentation
PDF
Introduction to R
PDF
Introduction to R software, by Leire ibaibarriaga
PPTX
Intro to big data analytics using microsoft machine learning server with spark
PDF
Introduction to python along with the comparitive analysis with r
PDF
An Analytics Toolkit Tour
PDF
R - the language
PDF
Microsoft R - Data Science at Scale
PDF
R meet up slides.pptx
PDF
R Programming Overview
PPTX
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
PPTX
R as supporting tool for analytics and simulation
PPT
An introduction to R is a document useful
PPTX
R introduction
Python and R for quantitative finance
吳齊軒/漫談 R 的學習挑戰與 R 語言翻轉教室
R Intro
Python vs. r for data science
R_L1-Aug-2022.pptx
R programming presentation
Introduction to R
Introduction to R software, by Leire ibaibarriaga
Intro to big data analytics using microsoft machine learning server with spark
Introduction to python along with the comparitive analysis with r
An Analytics Toolkit Tour
R - the language
Microsoft R - Data Science at Scale
R meet up slides.pptx
R Programming Overview
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
R as supporting tool for analytics and simulation
An introduction to R is a document useful
R introduction
Ad

More from Ruslan Shevchenko (20)

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

Recently uploaded (20)

PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
Visual explanation of Dijkstra's Algorithm using Python
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
AI Guide for Business Growth - Arna Softech
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Microsoft Office 365 Crack Download Free
PPTX
Cybersecurity: Protecting the Digital World
PDF
Time Tracking Features That Teams and Organizations Actually Need
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Advanced SystemCare Ultimate Crack + Portable (2025)
How to Use SharePoint as an ISO-Compliant Document Management System
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
GSA Content Generator Crack (2025 Latest)
Monitoring Stack: Grafana, Loki & Promtail
Visual explanation of Dijkstra's Algorithm using Python
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
CNN LeNet5 Architecture: Neural Networks
Topaz Photo AI Crack New Download (Latest 2025)
AI Guide for Business Growth - Arna Softech
Weekly report ppt - harsh dattuprasad patel.pptx
Microsoft Office 365 Crack Download Free
Cybersecurity: Protecting the Digital World
Time Tracking Features That Teams and Organizations Actually Need
Computer Software and OS of computer science of grade 11.pptx
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Designing Intelligence for the Shop Floor.pdf
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
The Dynamic Duo Transforming Financial Accounting Systems Through Modern Expe...

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