Distribute your R code with R package

Similar documents
Writing R packages. Tools for Reproducible Research. Karl Broman. Biostatistics & Medical Informatics, UW Madison

Object systems available in R. Why use classes? Information hiding. Statistics 771. R Object Systems Managing R Projects Creating R Packages

Package packrat. R topics documented: March 28, Type Package

Table of Contents. The RCS MINI HOWTO

Documentation Installation of the PDR code

CMPT 373 Software Development Methods. Building Software. Nick Sumner Some materials from Shlomi Fish & Kitware

The Einstein Depot server

Introduction to ROOT and data analysis

Supported platforms & compilers Required software Where to download the packages Geant4 toolkit installation (release 9.6)

Creating a Java application using Perfect Developer and the Java Develo...

Creating R Packages, Using CRAN, R-Forge, And Local R Archive Networks And Subversion (SVN) Repositories

Hypercosm. Studio.

Step by Step Tutorial to creating R Packages. Heng Wang Michigan State University

Eventia Log Parsing Editor 1.0 Administration Guide

1001ICT Introduction To Programming Lecture Notes

File Transfer Protocol (FTP) Chuan-Ming Liu Computer Science and Information Engineering National Taipei University of Technology Fall 2007, TAIWAN

3. Programming the STM32F4-Discovery

csce4313 Programming Languages Scanner (pass/fail)

DB Ingest. Database Ingest for EXOSAT DBMS

Thirty Useful Unix Commands

Grandstream Networks, Inc. XML Configuration File Generator User Guide

CDD user guide. PsN Revised


Improve Fortran Code Quality with Static Analysis

Computational Mathematics with Python

Smooks Dev Tools Reference Guide. Version: GA

LICENSE4J FLOATING LICENSE SERVER USER GUIDE

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft Internet Information Services Agent Version Fix Pack 2.

WIRIS quizzes web services Getting started with PHP and Java

Problems and Measures Regarding Waste 1 Management and 3R Era of public health improvement Situation subsequent to the Meiji Restoration

Computational Mathematics with Python

MatrixSSL Getting Started

SAIP 2012 Performance Engineering

AsiaBSDcon 2016: Getting Started with the FreeBSD Documentation and Translation Projects

How to translate VisualPlace

Parallel Processing using the LOTUS cluster

Using the Radmind Command Line Tools to. Maintain Multiple Mac OS X Machines

UNICORE UFTPD server UNICORE UFTPD SERVER. UNICORE Team

Image Acquisition Toolbox Adaptor Kit User's Guide

10 STEPS TO YOUR FIRST QNX PROGRAM. QUICKSTART GUIDE Second Edition

Guile Present. version 0.3.0, updated 21 September Andy Wingo

>

Command Line - Part 1

Top 10 Things to Know about WRDS

Improve Fortran Code Quality with Static Security Analysis (SSA)



Mastering CMake. Sixth Edition. Bill Martin & Hoffman. Ken. Andy Cedilnik, David Cole, Marcus Hanwell, Julien Jomier, Brad King, Robert Maynard,

GIVE WINGS TO YOUR IDEAS TOOLS MANUAL

Apache Thrift and Ruby

INT322. By the end of this week you will: (1)understand the interaction between a browser, web server, web script, interpreter, and database server.

HP Service Virtualization

Databricks Cloud Platform Native REST API 1.0

Xcode Project Management Guide. (Legacy)

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

How To Use Query Console


Installing (1.8.7) 9/2/ Installing jgrasp

Figure 1 TOE2-IP FTP Server Demo Environment Setup on KC705

Introduction CMake Language Specific cases. CMake Tutorial. How to setup your C/C++ projects? Luis Díaz Más.

ARDA Experiment Dashboard

Using Dedicated Servers from the game

Volume FIRST WALKTHROUGH. The 10-Minute Guide to Using Newsletter Services. First Walkthrough: the 10-Minute Guide

CUNY TUMBLEWEED (SECURE TRANSPORT) USER GUIDE

Beam Loss Monitor Software Guide

R12.2 Install/Patch/Maintain Oracle E-Business Suite

Evaluation of the CMT and SCRAM Software Configuration, Build and Release Management Tools

DiskPulse DISK CHANGE MONITOR

Introduction to the use of the environment of Microsoft Visual Studio 2008

Audit TM. The Security Auditing Component of. Out-of-the-Box

Application Note: AN00141 xcore-xa - Application Development

Introduction. What is an Operating System?

UNIX, Shell Scripting and Perl Introduction

Sheet 7 (Chapter 10)

Metric Tools for Java

RDM+ Remote Desktop for Android. Getting Started Guide

Optional Lab: Schedule Task Using GUI and at Command in Windows 7

INTEGRAL OFF-LINE SCIENTIFIC ANALYSIS

ACS 5.x and later: Integration with Microsoft Active Directory Configuration Example

List of FTP commands for the Microsoft command-line FTP client

ADITION ios Ad SDK Integration Guide for App Developers

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

PHP Debugging. Draft: March 19, Christopher Vickery

CSI Web Server for Linux Installation Guide 8/13

Magento Search Extension TECHNICAL DOCUMENTATION

WEB2CS INSTALLATION GUIDE

Welcome to the topic on queries in SAP Business One.

Tutorial: Packaging your server build

TightVNC for Windows: Server Command-Line Options

SIM900_Custom Application Building Tutorial_Application Note_V1.00

PostgreSQL extension s development

Transcription:

Distribute your R code with R package Feng Li feng.li@cufe.edu.cn School of Statistics and Mathematics Central University of Finance and Economics June 2, 2014 Revision: June 2, 2014

Today we are going to learn... Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 2 / 14

Why package Packages provide a mechanism for loading optional code, data and documentation as needed. Code and functions are documented. Easy to share. Provide easy interface in R for code written in other languages (C, Fortran...) Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 3 / 14

The R package structure The sources of an R package consists of a subdirectory containing a files DESCRIPTION and NAMESPACE, and the subdirectories R, data, demo, exec, inst, man, po, src, tests, tools and vignettes (some of which can be missing, but which should not be empty). The package subdirectory may also contain files INDEX, configure, cleanup, LICENSE, LICENCE and NEWS. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 4 / 14

The difference between source and binary packages Source package: you can check the source code. You need to compile it to make it binary. Binary package: Ready to use. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 5 / 14

The DESCRIPTION file The Package, Version, License, Description, Title, Author, and Maintainer fields are mandatory, all other fields are optional. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 6 / 14

The Licensing file It is very important that you include license information! Otherwise, it may not even be legally correct for others to distribute copies of the package, let alone use it. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 7 / 14

Package Dependencies The Depends field gives a comma-separated list of package names which this package depends on. Those packages will be attached before the current package when library or require is called. Each package name may be optionally followed by a comment in parentheses specifying a version requirement. The comment should contain a comparison operator, whitespace and a valid version number, e.g. MASS (>= 3.1-20). Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 8 / 14

The INDEX file The optional file INDEX contains a line for each sufficiently interesting object in the package, giving its name and a description. Normally this file is missing and the corresponding information is automatically generated from the documentation sources when installing from source. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 9 / 14

The R subdirectory The R subdirectory contains R code files, only. The code files to be installed must start with an ASCII (lower or upper case) letter or digit and have one of the extensions.r,.s,.q,.r, or.s. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 10 / 14

The man subdirectory I The man subdirectory should contain (only) documentation files for the objects in the package in R documentation (Rd) format A typical R function documentation \name{load} \alias{load} \title{reload Saved Datasets} \description{ Reload the datasets written to a file with the function \code{save}. } \usage{ load(file, envir = parent.frame()) } \arguments{ \item{file}{a connection or a character string giving the name of the file to load.} \item{envir}{the environment where the data should be loaded.} Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 11 / 14

The man subdirectory II } \seealso{ \code{\link{save}}. } \examples{ ## save all data save(list = ls(), file= "all.rdata") ## restore the saved values to the current environment load("all.rdata") ## restore the saved values to the workspace load("all.rdata",.globalenv) } \keyword{file} Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 12 / 14

Other files The sources and headers for the compiled code are in src, plus optionally a file Makevars or Makefile. The data subdirectory is for data files. Data files can have one of three types as indicated by their extension: plain R code (.R or.r), tables (.tab,.txt, or.csv, see?data for the file formats, and note that.csv is not the standard CSV format), or save() images (.RData or.rda). The demo subdirectory is for R scripts (for running via demo()) that demonstrate some of the functionality of the package. Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 13 / 14

Build a package Using R CMD check, the R package checker, one can test whether source R packages work correctly. Packages may be distributed in source form as âăijtarballsâăi (.tar.gz files) or in binary form. The source form can be installed on all platforms with suitable tools and is the usual form for Unix-like systems the binary form is platform-specific, and is the more common distribution form for the Windows and OS X platforms. Use the following commands to find more help under a termial. R CMD check --help R CMD build --help Feng Li (Stat & Math, CUFE) Statistical Software June 2, 2014 14 / 14