Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
R in Action, Second Edition.pdf
Скачиваний:
540
Добавлен:
26.03.2016
Размер:
20.33 Mб
Скачать

512

CHAPTER 21 Creating a package

respectively. For new submissions, confirm in the body of the email that you have read and agree to CRAN’s policies.

But please don’t upload the npar package you just created to CRAN! You now have the tools to create your own packages.

21.5 Going further

In this chapter, all the code used to create the npar package was R code. In fact, most packages contain code that is written entirely in R. But you can also call compiled C, C++, Fortran, and Java code from R. External code is typically included when doing so will improve execution speed or when the author wants to use existing external libraries from within their R code.

There are several methods for including compiled external code. Useful functions include .C(), .Fortran(), .External(), and .Call(). Several packages have also been written to facilitate the process, including inline (C, C++, Fortran), Rcpp (C++), and rJava (Java).

Adding external compiled code to an R package is beyond the scope of this book. The Writing R Extensions manual (http://cran.r-project.org/doc/manuals/R-exts

.html), along with the help files for these functions and packages, should provide you with enough details to get started. Stack Overflow (http://stackoverflow.com) is a great place to ask questions if you get stuck.

21.6 Summary

R packages are a great way to organize your frequently used functions, develop complete applications, and share your results with others. In this chapter, you created a complete R package that can be used for carrying out nonparametric group comparisons. These object-oriented techniques can be applied to many other data-manage- ment and data-analytic tasks. Although packages seem complicated at first, they’re pretty easy to create once you have the process down. Now, get to work! And remember, have fun out there.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]