SlideShare una empresa de Scribd logo
1 de 35
Descargar para leer sin conexión
R / C++ 
Romain François 
@romain_francois
• Use R since 2002 
• Consultant 
• Rcpp since 2010 
• Rcpp11 since 2013 
• Performance 
• Occasional comedy
useR2015 propaganda 
Please
useR2015 propaganda
C/R API
Rcpp
303 
ABSSeq accelerometry acer AdaptiveSparsity ALKr Amelia apcluster BalancedSampling BayesComm 
wordcloud wsrf XBRL zic bayou bcp bcpa bfa bfp bifactorial BIFIEsurvey BIPOD blockcluster btf bvarsv CARBayes 
CARBayesST ccaPP cda CDM cgAUC CIDnetworks cladoRcpp classify clere climdex.pcic clipper 
clogitL1 clusteval ClustVarLV CMF COMPASS CompGLM ConConPiWiFun coneproj copCAR CorReg 
Crossover cxxfunplus dbmss ddgraph Delaporte dendextendRcpp DepthProc DESeq2 devtools dils 
disclapmix diversitree diveRsity DNAprofiles DNAtools dplyr dslice DStree ecp EDDA eive 
EpiContactTrace ESGtoolkit EWGoF fastGHQuad FastHCS fastM FastPCS FastRCS FBFsearch fdaMixed 
FDRreg FisHiCal flip flowMatch flowType flowWorkspace FLSSS forecast fugeR Funclustering 
fwsim geiger GeneNetworkBuilder GeneticTools geoCount glcm GMCM gMWT GOSemSim GOSim 
GOsummaries GPvam gRbase GRENITS gRim growcurves growfunctions GSE GUILDS GUTS GxM hawkes 
HDPenReg HLMdiag hsphase httpuv HUM hyperSpec hypervolume iBATCGH IBHM icamix icensmis 
inarmix inline IsingSampler iterpc jaatha JAGUAR KernSmoothIRT kmc Kmisc LaF lbfgs lm.br lme4 
lsgl marked maxent mcIRT messina metafolio metaSeq mets mice miceadds MIMOSA minqa mirt miscF 
miscset mkde mmand Morpho mosaics Mposterior MPTinR msgl MSstats MTS mvabund MVB mvnfast 
mwaved mzR nabor ndl NetSim networkBMA ngspatial NPBayesImpute oem openair openxlsx orQA PBC 
pcalg pcaMethods PedCNV PerMallows phom phylobase planar plotSEMM plyr polywog PP PReMiuM 
pROC pRoloc propagate prospectr protViz pryr psgp QRM quadrupen qVarSel randomUniformForest 
Rankcluster rARPACK Rchemcpp Rclusterpp RcppArmadillo RcppBDT rcppbugs RcppClassic 
RcppClassicExamples RcppCNPy RcppDE RcppEigen RcppExamples RcppGSL RcppMLPACK RcppOctave 
RcppParallel RcppProgress RcppRedis RcppRoll RcppSMC RcppXts RcppZiggurat Rdisop recosystem 
remote ReorderCluster resemble reshape2 revealedPrefs rexpokit rforensicbatwing rgam RInside 
ripa Risa rkvo rlme RLRsim Rmalschains RMassBank rmgarch Rmixmod RmixmodCombi robustgam 
robustHD rococo rotations roxygen2 rpg rplexos rPref RProtoBuf RQuantLib RSNNS RSNPset RSofia 
Rsomoclu rTANDEM Rtsne Ruchardet rugarch Rvcg RVowpalWabbit sapFinder SBSA scrypt sdcMicro 
sdcTable SelvarMix SeqArray sequences sglOptim simFrame sirt slfm snplist SocialNetworks SOD 
spacodiR spaMM sparseHessianFD sparseLTSEigen SpatialEpi SpatialTools spBayesSurv StereoMorph 
stochvol stosim strum survAccuracyMeasures surveillance survSNP synlik TAM TAQMNGR tbart 
termstrc TFMPvalue treeclim trustOptim tvd unmarked VideoComparison VIM waffect WideLM
dplyr 
dplyr 
dplyr dplyr 
dplyr dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr dplyr 
dplyr 
dplyr 
dplyr dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr #rcatladies 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr dplyr 
dplyr 
dplyr 
dplyr 
dplyr 
dplyr dplyr
int add( int a, int b){ 
return a + b ; 
}
#include <Rcpp.h> 
! 
// [[Rcpp::export]] 
int add( int a, int b){ 
return a + b ; 
}
sourceCpp 
#include <Rcpp.h> 
! 
// [[Rcpp::export]] 
int add( int a, int b){ 
return a + b ; 
} 
> sourceCpp( "add.cpp" ) 
> add( 2L, 3L) 
[1] 5
R/c++ classes 
• NumericVector, IntegerVector, 
CharacterVector, … 
• List 
• Function 
• Environment …
// [[Rcpp::export]] 
double sum( NumericVector x){ 
int n = x.size() ; 
! 
double res = 0.0 ; 
for( int i=0; i<n; i++){ 
res += x[i] ; 
} 
! 
return res ; 
}
List res = List::create( 
_["a"] = 1, 
_["b"] = "foo" 
); 
res.attr( "class" ) = "myclass" ; ! 
int a = res["a"] ; 
res["b"] = 42 ;
Function rnorm( "rnorm" ) ; 
! 
NumericVector x = rnorm( 
10, 
_["mean"] = 30, 
_["sd"] = 100 
);
1998
C++114
C++
Range based for loops 
for( int i=0; i<x.size(); i++){ 
double d = x[i] ; 
// do something with d 
} 
for( double d: x){ 
// do something with d 
} 
C++11 C++98
auto 
std::vector<double> v = ... ; 
std::vector<double>::const_iterator it = v.begin() ; 
auto it = v.begin() ; 
C++98 
C++11
Uniform initialization {…} 
std::vector<std::string> x(2) ; 
x[0] = "foo"; x[1] = "bar" ; 
std::vector<std::string> x = {"foo", "bar"} ;
C++98 typical functor bloat 
class Predicate { 
public: 
Predicate( double y_ ) : y(y_){} 
! 
inline bool operator()(double x){ 
return x < y ; 
} 
! 
private: 
double y ; 
} ; 
... 
! 
double y = 2.0 ; 
std::count_if( v.begin(), v.end(), Predicate(y)) ;
C++11 Lambda 
double y = 2.0 ; 
std::count_if( v.begin(), v.end(), 
[=y](double x){ 
return x < y ; 
} 
) ;
Rcpp11
Rcpp11 
• C++ = C++11 
• Smaller code base (than Rcpp) 
• Header only
Less code -> faster compiles 
#include <Rcpp.h> 
! 
// [[Rcpp::export]] 
int foo(){ 
return 2 ; 
} 
Rcpp 
Rcpp11 
0 1 2 3
sapply + lambda 
#include <Rcpp11> 
! 
// [[export]] 
NumericVector foo( NumericVector x ){ 
return sapply(x, [](double d){ 
return exp(d * 2) ; 
}); 
} 
x <- 1:3 
sapply( x, function(d){ 
exp(d*2) ; 
})
Rcpp11 release cycle 
• Available from CRAN: 
! 
> install.packages( "Rcpp11" ) 
• Evolves quickly. Get it from github 
! 
> install_github( "Rcpp11/Rcpp11" ) 
• Current Version: 3.1.1 (same as R version)
Questions 
romain@r-enthusiasts.com 
@romain_francois

Más contenido relacionado

La actualidad más candente

All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
Moriyoshi Koizumi
 
5 1. character processing
5 1. character processing5 1. character processing
5 1. character processing
웅식 전
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
akaptur
 

La actualidad más candente (20)

A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
 
Go Concurrency
Go ConcurrencyGo Concurrency
Go Concurrency
 
Exploiting vectorization with ISPC
Exploiting vectorization with ISPCExploiting vectorization with ISPC
Exploiting vectorization with ISPC
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Modern c++ Memory Management
Modern c++ Memory ManagementModern c++ Memory Management
Modern c++ Memory Management
 
Golang Channels
Golang ChannelsGolang Channels
Golang Channels
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
C c++-meetup-1nov2017-autofdo
C c++-meetup-1nov2017-autofdoC c++-meetup-1nov2017-autofdo
C c++-meetup-1nov2017-autofdo
 
A formalization of complex event stream processing
A formalization of complex event stream processingA formalization of complex event stream processing
A formalization of complex event stream processing
 
Using zone.js
Using zone.jsUsing zone.js
Using zone.js
 
Go Concurrency Patterns
Go Concurrency PatternsGo Concurrency Patterns
Go Concurrency Patterns
 
GoでKVSを書けるのか
GoでKVSを書けるのかGoでKVSを書けるのか
GoでKVSを書けるのか
 
Go Concurrency Basics
Go Concurrency Basics Go Concurrency Basics
Go Concurrency Basics
 
5 1. character processing
5 1. character processing5 1. character processing
5 1. character processing
 
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
 
3 rd animation
3 rd animation3 rd animation
3 rd animation
 
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!..."A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
"A 1,500 line (!!) switch statement powers your Python!" - Allison Kaptur, !!...
 
Concurrency in Golang
Concurrency in GolangConcurrency in Golang
Concurrency in Golang
 
Clojure+ClojureScript Webapps
Clojure+ClojureScript WebappsClojure+ClojureScript Webapps
Clojure+ClojureScript Webapps
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japan
 

Similar a R/C++ talk at earl 2014

Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
Romain Francois
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
Romain Francois
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
Romain Francois
 
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfImplement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
meerobertsonheyde608
 
Extend R with Rcpp!!!
Extend R with Rcpp!!!Extend R with Rcpp!!!
Extend R with Rcpp!!!
mickey24
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
FFRI, Inc.
 
Lego: A brick system build by scala
Lego: A brick system build by scalaLego: A brick system build by scala
Lego: A brick system build by scala
lunfu zhong
 

Similar a R/C++ talk at earl 2014 (20)

Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
R and C++
R and C++R and C++
R and C++
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
Rcpp: Seemless R and C++
Rcpp: Seemless R and C++Rcpp: Seemless R and C++
Rcpp: Seemless R and C++
 
R and cpp
R and cppR and cpp
R and cpp
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdfImplement an MPI program to perform matrix-matrix multiplication AB .pdf
Implement an MPI program to perform matrix-matrix multiplication AB .pdf
 
Rcpp
RcppRcpp
Rcpp
 
Extend R with Rcpp!!!
Extend R with Rcpp!!!Extend R with Rcpp!!!
Extend R with Rcpp!!!
 
Exploring the x64
Exploring the x64Exploring the x64
Exploring the x64
 
Xdp and ebpf_maps
Xdp and ebpf_mapsXdp and ebpf_maps
Xdp and ebpf_maps
 
Native interfaces for R
Native interfaces for RNative interfaces for R
Native interfaces for R
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
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
 
Lego: A brick system build by scala
Lego: A brick system build by scalaLego: A brick system build by scala
Lego: A brick system build by scala
 
Lex (lexical analyzer)
Lex (lexical analyzer)Lex (lexical analyzer)
Lex (lexical analyzer)
 
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
Go Go Gadget! - An Intro to Return Oriented Programming (ROP)
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 

Más de Romain Francois (11)

R/C++
R/C++R/C++
R/C++
 
dplyr and torrents from cpasbien
dplyr and torrents from cpasbiendplyr and torrents from cpasbien
dplyr and torrents from cpasbien
 
dplyr use case
dplyr use casedplyr use case
dplyr use case
 
dplyr
dplyrdplyr
dplyr
 
SevillaR meetup: dplyr and magrittr
SevillaR meetup: dplyr and magrittrSevillaR meetup: dplyr and magrittr
SevillaR meetup: dplyr and magrittr
 
Data manipulation with dplyr
Data manipulation with dplyrData manipulation with dplyr
Data manipulation with dplyr
 
Rcpp attributes
Rcpp attributesRcpp attributes
Rcpp attributes
 
Rcpp is-ready
Rcpp is-readyRcpp is-ready
Rcpp is-ready
 
Rcpp
RcppRcpp
Rcpp
 
Object Oriented Design(s) in R
Object Oriented Design(s) in RObject Oriented Design(s) in R
Object Oriented Design(s) in R
 
RProtoBuf: protocol buffers for R
RProtoBuf: protocol buffers for RRProtoBuf: protocol buffers for R
RProtoBuf: protocol buffers for R
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

R/C++ talk at earl 2014

  • 1. R / C++ Romain François @romain_francois
  • 2. • Use R since 2002 • Consultant • Rcpp since 2010 • Rcpp11 since 2013 • Performance • Occasional comedy
  • 7.
  • 8.
  • 9. 303 ABSSeq accelerometry acer AdaptiveSparsity ALKr Amelia apcluster BalancedSampling BayesComm wordcloud wsrf XBRL zic bayou bcp bcpa bfa bfp bifactorial BIFIEsurvey BIPOD blockcluster btf bvarsv CARBayes CARBayesST ccaPP cda CDM cgAUC CIDnetworks cladoRcpp classify clere climdex.pcic clipper clogitL1 clusteval ClustVarLV CMF COMPASS CompGLM ConConPiWiFun coneproj copCAR CorReg Crossover cxxfunplus dbmss ddgraph Delaporte dendextendRcpp DepthProc DESeq2 devtools dils disclapmix diversitree diveRsity DNAprofiles DNAtools dplyr dslice DStree ecp EDDA eive EpiContactTrace ESGtoolkit EWGoF fastGHQuad FastHCS fastM FastPCS FastRCS FBFsearch fdaMixed FDRreg FisHiCal flip flowMatch flowType flowWorkspace FLSSS forecast fugeR Funclustering fwsim geiger GeneNetworkBuilder GeneticTools geoCount glcm GMCM gMWT GOSemSim GOSim GOsummaries GPvam gRbase GRENITS gRim growcurves growfunctions GSE GUILDS GUTS GxM hawkes HDPenReg HLMdiag hsphase httpuv HUM hyperSpec hypervolume iBATCGH IBHM icamix icensmis inarmix inline IsingSampler iterpc jaatha JAGUAR KernSmoothIRT kmc Kmisc LaF lbfgs lm.br lme4 lsgl marked maxent mcIRT messina metafolio metaSeq mets mice miceadds MIMOSA minqa mirt miscF miscset mkde mmand Morpho mosaics Mposterior MPTinR msgl MSstats MTS mvabund MVB mvnfast mwaved mzR nabor ndl NetSim networkBMA ngspatial NPBayesImpute oem openair openxlsx orQA PBC pcalg pcaMethods PedCNV PerMallows phom phylobase planar plotSEMM plyr polywog PP PReMiuM pROC pRoloc propagate prospectr protViz pryr psgp QRM quadrupen qVarSel randomUniformForest Rankcluster rARPACK Rchemcpp Rclusterpp RcppArmadillo RcppBDT rcppbugs RcppClassic RcppClassicExamples RcppCNPy RcppDE RcppEigen RcppExamples RcppGSL RcppMLPACK RcppOctave RcppParallel RcppProgress RcppRedis RcppRoll RcppSMC RcppXts RcppZiggurat Rdisop recosystem remote ReorderCluster resemble reshape2 revealedPrefs rexpokit rforensicbatwing rgam RInside ripa Risa rkvo rlme RLRsim Rmalschains RMassBank rmgarch Rmixmod RmixmodCombi robustgam robustHD rococo rotations roxygen2 rpg rplexos rPref RProtoBuf RQuantLib RSNNS RSNPset RSofia Rsomoclu rTANDEM Rtsne Ruchardet rugarch Rvcg RVowpalWabbit sapFinder SBSA scrypt sdcMicro sdcTable SelvarMix SeqArray sequences sglOptim simFrame sirt slfm snplist SocialNetworks SOD spacodiR spaMM sparseHessianFD sparseLTSEigen SpatialEpi SpatialTools spBayesSurv StereoMorph stochvol stosim strum survAccuracyMeasures surveillance survSNP synlik TAM TAQMNGR tbart termstrc TFMPvalue treeclim trustOptim tvd unmarked VideoComparison VIM waffect WideLM
  • 10. dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr #rcatladies dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr dplyr
  • 11. int add( int a, int b){ return a + b ; }
  • 12.
  • 13. #include <Rcpp.h> ! // [[Rcpp::export]] int add( int a, int b){ return a + b ; }
  • 14. sourceCpp #include <Rcpp.h> ! // [[Rcpp::export]] int add( int a, int b){ return a + b ; } > sourceCpp( "add.cpp" ) > add( 2L, 3L) [1] 5
  • 15. R/c++ classes • NumericVector, IntegerVector, CharacterVector, … • List • Function • Environment …
  • 16. // [[Rcpp::export]] double sum( NumericVector x){ int n = x.size() ; ! double res = 0.0 ; for( int i=0; i<n; i++){ res += x[i] ; } ! return res ; }
  • 17. List res = List::create( _["a"] = 1, _["b"] = "foo" ); res.attr( "class" ) = "myclass" ; ! int a = res["a"] ; res["b"] = 42 ;
  • 18. Function rnorm( "rnorm" ) ; ! NumericVector x = rnorm( 10, _["mean"] = 30, _["sd"] = 100 );
  • 19. 1998
  • 20.
  • 21.
  • 23. C++
  • 24. Range based for loops for( int i=0; i<x.size(); i++){ double d = x[i] ; // do something with d } for( double d: x){ // do something with d } C++11 C++98
  • 25. auto std::vector<double> v = ... ; std::vector<double>::const_iterator it = v.begin() ; auto it = v.begin() ; C++98 C++11
  • 26. Uniform initialization {…} std::vector<std::string> x(2) ; x[0] = "foo"; x[1] = "bar" ; std::vector<std::string> x = {"foo", "bar"} ;
  • 27. C++98 typical functor bloat class Predicate { public: Predicate( double y_ ) : y(y_){} ! inline bool operator()(double x){ return x < y ; } ! private: double y ; } ; ... ! double y = 2.0 ; std::count_if( v.begin(), v.end(), Predicate(y)) ;
  • 28. C++11 Lambda double y = 2.0 ; std::count_if( v.begin(), v.end(), [=y](double x){ return x < y ; } ) ;
  • 30. Rcpp11 • C++ = C++11 • Smaller code base (than Rcpp) • Header only
  • 31.
  • 32. Less code -> faster compiles #include <Rcpp.h> ! // [[Rcpp::export]] int foo(){ return 2 ; } Rcpp Rcpp11 0 1 2 3
  • 33. sapply + lambda #include <Rcpp11> ! // [[export]] NumericVector foo( NumericVector x ){ return sapply(x, [](double d){ return exp(d * 2) ; }); } x <- 1:3 sapply( x, function(d){ exp(d*2) ; })
  • 34. Rcpp11 release cycle • Available from CRAN: ! > install.packages( "Rcpp11" ) • Evolves quickly. Get it from github ! > install_github( "Rcpp11/Rcpp11" ) • Current Version: 3.1.1 (same as R version)