{"id":203,"date":"2021-03-13T18:10:19","date_gmt":"2021-03-13T18:10:19","guid":{"rendered":"http:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ziyang-yang\/?p=203"},"modified":"2021-04-30T12:58:26","modified_gmt":"2021-04-30T12:58:26","slug":"3-steps-to-build-own-r-package-rcpp","status":"publish","type":"post","link":"https:\/\/www.lancaster.ac.uk\/stor-i-student-sites\/ziyang-yang\/2021\/03\/13\/3-steps-to-build-own-r-package-rcpp\/","title":{"rendered":"3 steps to build own R package – Rcpp"},"content":{"rendered":"\n

This blog is to give ideas how to build R package through Rcpp and C++. Here we assume our readers are confident of C++, Linux and R.<\/span><\/p>\n\n\n\n

This semester we have been trained to use C++ and Rcpp to write the R package. It is well known that the computing speed of R is slower than C++. Rcpp is an R Package that combines C++ and R. With Rcpp, it could easily transfer the algorithm or functions between R and C++, providing high-performance statistical computing to most R users. It is useful when statisticians want to develop their own R package. So, I will write it in 3 steps and using an Example.<\/p>\n\n\n\n


\n\n\n\n

Step 1: Write your own algorithm in C++<\/h1>\n\n\n\n

Firstly, you have to write your own algorithm in C++ in a Linux system. And next, we have to add some code in C++ to make sure it could be translated by R:<\/p>\n\n\n\n