写在前面啰嗦下
像R
,python
这样的高级语言,虽然上手快,也比较好入门。但是当遇到编写循环迭代等算法的时候,程序运行效率往往很慢。如果可以向量化,用内建函数那就试试。实在不行建议用C++
吧。如果你想把C++
与R
程序连接起来。那就试试Rcpp
吧。什么是Rcpp
,直接上Description
。
packageDescription("Rcpp")$Description
## [1] "The 'Rcpp' package provides R functions as well as C++ classes which\n offer a seamless integration of R and C++. Many R data types and objects can be\n mapped back and forth to C++ equivalents which facilitates both writing of new\n code as well as easier integration of third-party libraries. Documentation\n about 'Rcpp' is provided by several vignettes included in this package, via the\n 'Rcpp Gallery' site at , the paper by Eddelbuettel and\n Francois (2011, <10.18637>), the book by Eddelbuettel (2013,\n <10.1007>) and the paper by Eddelbuettel and Balamuta (2018,\n <10.1080>); see 'citation(\"Rcpp\")' for details."10.1080>10.1007>10.18637>
编写例子
在这里我写了一个统计fastq
文件的Q20
, Q30
, GC
, average length
, total base