没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Writing R Extensions Version 1.8.1 (2003-11-21)R Development Core TeamPermission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the con- ditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is grante
资源推荐
资源详情
资源评论
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![whl](https://img-home.csdnimg.cn/images/20210720083646.png)
![msi](https://img-home.csdnimg.cn/images/20210720083646.png)
![xz](https://img-home.csdnimg.cn/images/20210720083646.png)
![jar](https://img-home.csdnimg.cn/images/20210720083646.png)
![jar](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/release/download_crawler_static/16820662/bg1.jpg)
Writing R Extensions
Version 1.8.1 (2003-11-21)
R Development Core Team
![](https://csdnimg.cn/release/download_crawler_static/16820662/bg2.jpg)
Permission is granted to make and distribute verbatim copies of this manual provided the
copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the con-
ditions for verbatim copying, provided that the entire resulting derived work is distributed
under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another lan-
guage, under the above conditions for modified versions, except that this permission notice
may be stated in a translation approved by the R Development Core Team.
Copyright
c
1999–2003 R Development Core Team
ISBN 3-900051-04-6
![](https://csdnimg.cn/release/download_crawler_static/16820662/bg3.jpg)
i
Table of Contents
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1 Creating R packages . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Package structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 The ‘DESCRIPTION’ file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.2 The ‘INDEX’ file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.3 Package subdirectories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.4 Package bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Configure and cleanup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.1 Using ‘Makevars’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Checking and building packages . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Writing package vignettes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.5 Submitting a package to cran . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.6 Package name spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 Writing R documentation files . . . . . . . . . . . . . 16
2.1 Rd format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.1 Documenting functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1.2 Documenting data sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.1.3 Documenting S4 classes and methods . . . . . . . . . . . . . . . . . . 21
2.2 Sectioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3 Marking text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.4 Lists and tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5 Cross-references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.6 Mathematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.7 Insertions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.8 Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.9 Platform-specific documentation . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.10 Processing Rd format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3 Tidying and profiling R code . . . . . . . . . . . . . . 27
3.1 Tidying R code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.2 Profiling R code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
![](https://csdnimg.cn/release/download_crawler_static/16820662/bg4.jpg)
ii
4 System and foreign language interfaces . . . . . 30
4.1 Operating system access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.2 Interface functions .C and .Fortran . . . . . . . . . . . . . . . . . . . . . 30
4.3 dyn.load and dyn.unload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4 Registering native routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.5 Creating shared objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.6 Interfacing C++ code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.7 Handling R objects in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.7.1 Handling the effects of garbage collection . . . . . . . . . . . . . . . 38
4.7.2 Allocating storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.7.3 Details of R types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.7.4 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.7.5 Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.7.6 Handling lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.7.7 Finding and setting variables . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.8 Interface functions .Call and .External . . . . . . . . . . . . . . . . 44
4.8.1 Calling .Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.8.2 Calling .External . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.8.3 Missing and special values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.9 Evaluating R expressions from C . . . . . . . . . . . . . . . . . . . . . . . . 48
4.9.1 Zero-finding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.9.2 Calculating numerical derivatives . . . . . . . . . . . . . . . . . . . . . . 50
4.10 Parsing R code from C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.11 Debugging compiled code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.11.1 Finding entry points in dynamically loaded code . . . . . . . 54
4.11.2 Inspecting R objects when debugging . . . . . . . . . . . . . . . . . 55
5 The R api: entry points for C code . . . . . . . . 57
5.1 Memory allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1.1 Transient storage allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.1.2 User-controlled memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.2 Error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.2.1 Error handling from FORTRAN . . . . . . . . . . . . . . . . . . . . . . . 58
5.3 Random number generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.4 Missing and ieee special values . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.5 Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.5.1 Printing from FORTRAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.6 Calling C from FORTRAN and vice versa . . . . . . . . . . . . . . . . 60
5.7 Numerical analysis subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.7.1 Distribution functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
5.7.2 Mathematical functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.7.3 Utilities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
5.7.4 Mathematical constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
5.8 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
5.9 Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
5.10 Utility functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.11 Platform and version information . . . . . . . . . . . . . . . . . . . . . . . 68
5.12 Using these functions in your own C code . . . . . . . . . . . . . . . 69
![](https://csdnimg.cn/release/download_crawler_static/16820662/bg5.jpg)
iii
6 Generic functions and methods . . . . . . . . . . . . 70
6.1 Adding new generics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Appendix A R (internal) programming
miscellanea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
A.1 .Internal and .Primitive . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
A.2 Testing R code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Appendix B R coding standards . . . . . . . . . . . . 74
Function and variable index . . . . . . . . . . . . . . . . . . 76
Concept index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
剩余84页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_38677190
- 粉丝: 6
- 资源: 891
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)