Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
R and C++. Past Present and Future.
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Romain
April 05, 2017
Technology
470
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
R and C++. Past Present and Future.
R and C++. Past Present and Future. Presented at the MilanoR meetup on 2017-04-05
Romain
April 05, 2017
Other Decks in Technology
See All in Technology
Data + AI Summit 2026 イベントレポート: 「AIがビジネスで意思決定するデータ基盤」へ
nek0128
0
190
そのドキュメント、自動化しませんか?
yuksew
1
140
ゴールデンパスは敷いただけでは道にならない ─ 企画部門のエンジニアが技術標準を事業価値に変えるまで
mhrtech
1
170
AI Agent SaaS を支える自社仮想化基盤への挑戦と実運用 / ai-agent-saas-virtualization
flatt_security
3
4k
AI時代の闇と光
tatsuya1970
0
100
Terraform共通モジュールをチーム横断で“変えられる”運用へ ― リリースと適用の分離
kekke_n
1
3.1k
Genie Ontologyは銀の弾丸かを考える / Is Genie Ontology a Silver Bullet?
nttcom
0
330
AIレビューはどこまで任せられるのか?自動化と人が背負うレビューの境界
sansantech
PRO
3
930
DMM.com 購入改善推進チーム におけるCodeRabbitを用いた レビューフロー改善の一例
ysknsid25
2
640
誤解だらけの開発生産性 / Myths and Misconceptions about Developer Productivity
i35_267
2
710
公式ドキュメントの歩き方etc
coco_se
0
110
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
8.4k
Featured
See All Featured
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
260
We Have a Design System, Now What?
morganepeng
55
8.2k
The Spectacular Lies of Maps
axbom
PRO
1
860
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
120k
Crafting Experiences
bethany
1
210
Skip the Path - Find Your Career Trail
mkilby
1
170
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
720
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.3k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
240
Transcript
R and C++ Past, Present and Future Romain François Consulting
Datactive
[email protected]
@romain_francois
None
None
None
Training / Development / Support @thinkR_fr
Rcpp
devtools::revdep( "Rcpp") ABCoptim AbsFilterGSEA acc accelerometry acebayes ACEt acrt AdaptiveSparsity
ADMMnet AhoCorasickTrie AHR alakazam algstat AlignStat ALKr alphabetr Amelia anytime apcluster arrApply ashr ASPBay aSPU attrCUSUM autovarCore BaBooN BacArena baitmet BalancedSampling BAMBI BAMMtools Barycenter BatchMap batman bayesAB BayesBD BayesComm bayesDP BayesFactor BayesianTools bayesImageS bayesm bayou bcp bcpa bcROCsurface BCSub bea.R beanz BEDMatrix benchr BeviMed beyondWhittle bfa bifactorial bife BIFIEsurvey biganalytics bigFastlm biglasso bigmemory BigQuic bigReg bigtabulate BigVAR bindrcpp bio3d Biocomb BIPOD biwavelet blackbox blockcluster blockmodels blockseg BLPestimatoR bmlm bnnSurvival BNSL bootTimeInference bridgesampling brms bsearchtools btb btf BTLLasso BTR BTYDplus BuyseTest bvarsv bWGR BWStest CARBayes CARBayesST catlearn ccaPP cccp ccdrAlgorithm cda CDF.PSIdekick CDM CFC cgAUC ChannelAttribution chopthin CIDnetworks CircularDDM cIRT cladoRcpp classifierplots classify cleanEHR clere climdex.pcic clogitboost clogitL1 clusrank ClusterR ClusterStability clusteval ClustMMDD ClustVarLV CMF CNull coala CoFRA collUtils combiter CompGLM ConConPiWiFun coneproj contoureR copCAR cord CorReg Countr Coxnet CoxPlus cpgen cpr cqrReg crawl creditr crmPack Crossover cstab ctmcd cubature CVR cxxfunplus cycleRtools Cyclops D3M darch dbmss dbscan ddalpha ddR DDRTree deepboost DeLorean densityClust DEploid DepthProc DescTools DetMCD DetR devtools dfcomb dfmta dfphase1 dfpk diagis DiffNet diffrprojects DiffusionRgqd DiffusionRimp DiffusionRjgqd diffusr dils dina disclapmix discretecdAlgorithm diversitree diveRsity divest dlib DLMtool DNAtools dnc dplyr drgee dslice DStree dtwclust dynamichazard dynsbm easyVerification EBMAforecast ECctmc ecp EditImputeCont eDMA eggCounts eive EloChoice EMbC emil emIRT energy EPGLM erah esaddle ESGtoolkit EstHer ETAS eulerr evolqg EWGoF exif extraDistr factorcpt FactoRizationMachines factorstochvol fastAdaboost FastBandChol fastcmh fasteraster fastGHQuad FastGP FastHCS fastHorseshoe fastJT fastM FastPCS FastRCS FBFsearch fbroc FCNN4R fdaMixed fdapace fdasrvf FDGcopulas FDRreg feather FeatureHashing ffstream FIACH fICA filesstrings FisHiCal FIT flam flan flars flexsurv flip flock FLSSS forecast forecastSNSTS forega forestFloor fourierin fourPNO fractional frailtyEM frailtySurv FRESA.CAD FRK fromo FSelectorRcpp FSInteract fst fugeR FunChisq Funclustering futureheatwaves fwsim gamreg gapfill GAS gaselect gaston GauPro gbp gcKrig GCPM GDINA gdm gdpc gdtools gee4 GEEaSPU geiger genie GENLIB GenomicTools geoCount geohash geojsonR GERGM ggdmc ggforce ggraph ggrepel GiRaF gjam gkmSVM glamlasso glcm GLMaSPU glmBfp glmgraph glmmsr GMCM Gmedian Gmisc gmum.r gmwm gMWT gogamer googleway GPareto gpuR GPvam gRain graphicalVAR graphkernels GraphKit graphql grattan gRbase gRim grove growcurves growfunctions GSE gsEasy gsynth GUILDS GUTS gwfa GWmodel GxM h5 hashmap haven hawkes hBayesDM HDPenReg hierarchicalSets hit hkevp HLMdiag hmi HSAR hsphase htdp htmltidy htmltools hts httpuv HUM humaniformat humarray hunspell hyperSpec hypervolume hyphenatr IAPWS95 iBATCGH IBHM ibm ibmcraftr iBST icamix ICAOD iccbeta icd icd9 icenReg icensmis icRSF ICtest ie2misc iemisc IHSEP iLaplace imager imagine immer imputeMulti inarmix inca indelmiss iNextPD inferr inline IntegratedMRF interflex ipft iprior iptools IRTpp IsingSampler isoph ISOpureR IsoSpecR iterpc JacobiEigen JAGUAR jiebaR jmcm jmotif joineRML joinXL JOUSBoost jqr JSM jtGWAS jwutil kamila kdecopula kdevine kergp kernDeepStackNet KernelKnn KernSmoothIRT kmc kmeans.ddR Kmisc KODAMA kohonen KoulMde l0ara LaF LambertW lamW LANDD Langevin largeVis LassoBacktracking lasvmR LatentREGpp lbfgs LBSPR lclGWAS lcopula lexRankr lfl lidR lifecontingencies lm.br lme4 lowmemtkmeans lpme lsbclust lsgl lucr ludic Luminescence MADPop mafs magick MAINT.Data ManifoldOptim mapview marked markophylo markovchain MAT matchingMarkets matchingR MatchItSE mateable MatrixCorrelation MatrixLDA MAVE maxent mbbefd mcemGLM mcga mcIRT mcmcse mcPAFit medfate MediaK MEGENA MESS metafolio MetaheuristicFPA meteoland mets mev mgm mice miceadds microclass microseq milr minimaxdesign minqa mirt mirtCAT miscF miscset MiSPU missDeaths MixAll MixedDataImpute mixedMem mixlink mixpack mixR mkde mlmc mlxR mmand ModelMetrics Morpho mousetrap move moveHMM moveWindSpeed mp Mposterior MPTinR mrfDepth mrgsolve MRS MSGARCH msgl MTS multdyn MultiBD multicool multinet MultivariateRandomForest mvabund MVB mvcluster mvnfast mwaved myTAI nabor NAM ndjson ndl NestedCategBayesImpute netcoh netdiffuseR NetRep NetSim NetworkInference neuroim ngspatial NHMM nmfgpu4R NNLM noncompliance nonlinearTseries NPBayesImpute NPflow nprobust nse odbc odeintr oem officer OjaNP olctools OneArmPhaseTwoStudy onlinePCA ontologySimilarity openair OpenImageR OpenMx openxlsx optimization optiSel optmatch opusminer orQA PAC packcircles pacotest padr PAFit palm pander PanelCount partialAR patternplot pcalg pcIRT pdftools pdp pdSpecEst PedCNV pedometrics penalized PenCoxFrail penMSM perccal PerMallows pgee.mixed ph2bayes ph2bye phangorn phonics phybreak phylobase phylocurve PhylogeneticEM phylosignal Pijavski pinbasic pirate plac planar planor PLMIX plogr plotSEMM plyr poisDoubleSamp polyfreqs polywog POUMM PoweR PP PPtreeViz prclust precrec PReMiuM primes ProbitSpatial pROC prodlim ProFit ProNet propagate prophet propr prospectr protolite prototest protViz pryr psd psgp purrr pvar PWD pystr qrencoder QRM quadrupen qualpalr quanteda quantspec QuantTools queuecomputer qVarSel qwraps2 radiomics rags2ridges ragt2ridges ramcmc randomUniformForest ranger Rankcluster rankdist raptr raster Rblpapi Rborist Rcereal Rclusterpp RcppAnnoy RcppAPT RcppArmadillo RcppBDT RcppBlaze RcppCCTZ RcppClassic RcppClassicExamples RcppCNPy RcppDE RcppDL RcppEigen RcppExamples RcppFaddeeva RcppGetconf RcppGSL RcppHMM RcppHoney RcppMLPACK RcppNumerical RcppOctave RcppParallel RcppProgress RcppRedis RcppRoll RcppShark RcppSMC RcppStreams RcppTOML RcppXts RcppZiggurat rcss rdist Rdtq readr readstata13 readxl RealVAMS recexcavAAR recmap reconstructr recosystem redist rEDM regsem ReIns relSim rem remote ReorderCluster repolr resemble reshape2 reticulate revealedPrefs rexpokit Rfast rflann rforensicbatwing rFTRLProximal rgam rgeolocate RI2by2 RInside Rip46 ripa rIsing riskRegression rivr rkvo Rlabkey rlas Rlda Rlibeemd RLRsim RLumModel Rmalschains rmgarch Rmixmod RmixmodCombi rmumps rncl RNifti RNiftyReg robCompositions robets robustgam RobustGaSP robustHD robustlmm robustreg rococo roll rollply rootWishart rotations RoughSets roxygen2 rpg Rphylopars rpms rPref RProtoBuf RPtests RQuantLib rrr RSNNS RSNPset Rsomoclu RSpectra RSQLite RSSL rstan rstanarm RStoolbox rstpm2 rtext rtk rtkore Rtsne Ruchardet rucrdtw rugarch Rvcg rvg Rvoterdistance RVowpalWabbit rwfec rwirelesscom Ryacas s2 saeRobust SAMM satellite saturnin sbart sbfc sBIC sbmSDP sbrl SBSA scales SciencesPo scorer scoringRules scrm scrypt scvxclustr sdcMicro sdcTable secure SEERaBomb segmag seismicRoll SelvarMix semver seqHMM sequences sf sgd sglOptim sharpeRratio signalHsmm simFrame simmer simPop SimReg simstudy sirt sitmo skm slfm SLOPE smam SmartSVA SMMA smoof smooth SnakeCharmR snipEM snowboot snplist SocialNetworks SOD SpaCCr spacodiR spaMM SparseFactorAnalysis sparseHessianFD sparseLTSEigen sparsepp sparsereg spass spatgraphs SpatialEpi SpatialTools SpaTimeClus SpatMCA SpatPCA spBayesSurv spduration SpecsVerification spectral sppmix spray spsann SSL starma staTools stdvectors steadyICA StepwiseTest StereoMorph stlplus stm StMoSim stochvol stocks stosim stplanr stpm strat strataG stream stremr striprtf strum supc SuperRanker survAccuracyMeasures surveillance surveybootstrap survSNP svglite SVMMatch synchronicity synlik synthACS systemicrisk tagcloud TAM TAQMNGR TauStar tbart tcR TDA tensorBSS termstrc TESS tesseract testforDEP text2vec textmineR textreg textreuse textTinyR TFMPvalue tibble tidyr tidyxl timma TLMoments tm tmg tmlenet tnam tokenizers TransferEntropy TreeBUGS treeclim treeplyr treescape treespace triebeard trustOptim tsBSS tvd tweenr UncerIn2 unmarked unsystation urltools V8 validatejsonr valr valuer varband varbvs VarSelLCM vcfR vdiffr velox VideoComparison VIM vita VNM waffect walkr wand wCorr webreadr wicket wingui Wmisc wordcloud wordspace wrswoR wsrf XBRL xml2 xslt xyz yakmoR yCrypticRNAs yuima zic ziphsmm 1001 9.63 %
devtools::revdep( "Rcpp", recursive = TRUE) 7812 75.23 %
*.h 95 235 *.cpp 5 698 100 933 *.R 3
177
motivation
int add( int a, int b ){ return a +
b ; } > add( 40, 2 ) [1] 42
past C/R API
#include <R.h> #include <Rinternals.h> int add( int a, int b
){ return a + b ; } SEXP add_c( SEXP a_, SEXP b_ ){ int a = INTEGER(a_)[0], b = INTEGER(b_)[0] ; int res = add( a, b ) ; SEXP result = PROTECT(allocVector(INTSXP, 1) ) ; INTEGER(result)[0] = res ; UNPROTECT(1) ; return result ; }
add <- function(a, b){ .Call( "add_c", a, b ) }
> add( 40, 2 ) Error in add(33, 9) : INTEGER() can only be applied to a 'integer', not a 'double' > add( 40L, 2L ) [1] 42
add <- function(a, b){ .Call( "add_c", as.integer(a), as.integer(b) ) }
> add( 40, 2 ) [1] 42 > add( 40L, 2L ) [1] 42
Tools • SEXP • INTEGER • PROTECT • allocVector •
INTSXP • UNPROTECT • .Call • as.integer
present Rcpp
#include <Rcpp.h> // [[Rcpp::export]] int add( int a, int b
){ return a + b ; } > add( 17L, 25L ) [1] 42 > add( 17, 25 ) [1] 42
example
None
! weighted_mean_1 <- function(x, w) { total <- 0 total_w
<- 0 for (i in seq_along(x)) { total <- total + x[i] * w[i] total_w <- total_w + w[i] } total / total_w }
" weighted_mean_2 <- function(x, w) { sum(x*w) / sum(w) }
# weighted.mean
$ #include <Rcpp.h> using namespace Rcpp ; // [[Rcpp::export]] double
weighted_mean_cpp( NumericVector x, NumericVector w){ int n = x.size() ; double total = 0.0 ; double total_w = 0.0 ; for( int i=0; i<n; i++){ total += x[i] * w[i] ; total_w += w[i] ; } return total / total_w ; }
None
None
future ?
Rcpp is like usb …
… but we want usb-c
Rcpp is too huge and not modular
Rcpp n + 2 core sugar modules core modules Rcpp
n +1 core sugar modules core modules Rcpp n core sugar modules core modules % mypkg ' ✔ $ )
proposal
NumericVector IntegerVector CharacterVector Function sugar modules … IntegerVector CharacterVector Function
sugar NumericVector core core modules … core pkg1 pkg2 core pkg3 core CharacterVector IntegerVector NumericVector
' ✔ $ ) ✔ ✔
Pros • Smaller • Faster • Robust • Controlled updates
Cons • More copies of code base • Maybe more testing
None
http://bit.ly/milanorcpp