Incorporating C++ code in an R package with Rcpp and devtools (CC288)

Описание к видео Incorporating C++ code in an R package with Rcpp and devtools (CC288)

Sometimes R code just isn't fast enough. When you've tried all of the other options, rewriting the R code in C++ can be a great option. In this Code Club, Pat uses the Rcpp package to add C++ code to his phylotypr package. Using the devtools use_rcpp function he shows how to create the framework for incorporating C++ code. Then he uses the microbenchmark package to optimize his Rcpp code to see if he can make it faster than his base R code. Can he do it? This episode is part of an ongoing effort to develop an R package that implements the naive Bayesian classifier.

If you want to get a physical copy of R Packages: https://amzn.to/43pMR8L
If you want a free, online version of R packages: https://r-pkgs.org/

You can find my blog post for this episode at https://www.riffomonas.org/code_club/....

Check out the GitHub repository at the:
* Beginning of the episode: https://github.com/riffomonas/phyloty...
* End of the episode: https://github.com/riffomonas/phyloty...


#rstats #paste #paste0 #refactor #testthat #tdd #microbenchmark #vectors #rdp #16S #classification #classifier #microbialecology #microbiome

Support Riffomonas by becoming a Patreon member!
  / riffomonas  

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

If you're interested in purchasing a video workshop be sure to check out https://riffomonas.org/workshops/

You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/



0:00 Introduction
3:31 Getting set up to use Rcpp in a package
6:11 Writing Rcpp/C++ version of function
15:35 Optimize performance of Rcpp code
23:03 Tradeoffs with using Rcpp vs. pure R
24:07 Committing changes to repository

Комментарии

Информация по комментариям в разработке