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



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

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

HOWTO configure Xinu under Virtual Box

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

Distribute your R code with R package

How to FTP (How to upload files on a web-server)

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

JAVS Scheduled Publishing. Installation/Configuration... 4 Manual Operation... 6 Automating Scheduled Publishing... 7 Windows XP... 7 Windows 7...

The IDL Virtual Machine

SCUtils WorkItem Scheduler Guide Solution for Microsoft System Center 2012 Service Manager

Desktop Web Access Single Sign-On Configuration Guide

INSTALLING MALTED 3.0 IN LINUX MALTED: INSTALLING THE SYSTEM IN LINUX. Installing Malted 3.0 in LINUX

Lab 5 Managing Access to Shared Folders

CONFIGURING TARGET ACTIVE DIRECTORY DOMAIN FOR AUDIT BY NETWRIX AUDITOR

Symantec Client Firewall Policy Migration Guide

Bulk Downloader. Call Recording: Bulk Downloader

Using CertAgent to Obtain Domain Controller and Smart Card Logon Certificates for Active Directory Authentication

SAS Visual Analytics 7.2 for SAS Cloud: Quick-Start Guide

Laptop Backup - User Guide (Windows)

[T9J1][User Guide] TASK MANAGER DELUXE USER GUIDE

Installation...2 Installation of Athena Visual Studio...2 Authorization...3 Authorization for Corporate License Users...3 Authorization for

Version Control with Subversion and Xcode

NDSR Utilities. Creating Backup Files. Chapter 9

ATBONLINE BUSINESS. Customer User Guide Exporting Account Information to.ofx Format Software (Simply Accounting).

Help File. Version February, MetaDigger for PC

PuTTY/Cygwin Tutorial. By Ben Meister Written for CS 23, Winter 2007

3D Restoration (Kine3D -3)

Cygwin: getting the setup tool

Android Environment SDK

How to install phpbb forum on NTU student club web server

October, Install/Uninstall Xerox Print Drivers & Apps Best Practices for Windows 8, 8.1, and 10 Customer Tip

Ready Reference Guide. Converting from Other Bibliographic Management Software

How to Configure Windows 8.1 to run ereports on IE11

How to deploy fonts using Configuration Manager 2012 R2

Instructions for Accessing the Advanced Computing Facility Supercomputing Cluster at the University of Kansas

Introduction to Eclipse

MaxSea TZ: Microsoft SQL Server problems End User

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

A brief Guide to checking your Group Policy Health

Installing FEAR on Windows, Linux, and Mac Systems

Primavera P6 Professional Windows 8 Installation Instructions. Primavera P6. Installation Instructions. For Windows 8 Users

Using Internet or Windows Explorer to Upload Your Site

Opening a Command Shell

Web VTS Installation Guide. Copyright SiiTech Inc. All rights reserved.

Modelling with R and MySQL. - Manual - Gesine Bökenkamp, Frauke Wiese, Clemens Wingenbach

EBSCO MEDIA FILE TRANSFER SOFTWARE INSTALLATION INSTRUCTIONS

ACTIVE DIRECTORY DEPLOYMENT

Create, Link, or Edit a GPO with Active Directory Users and Computers

STATISTICA VERSION 9 STATISTICA ENTERPRISE INSTALLATION INSTRUCTIONS FOR USE WITH TERMINAL SERVER

StarWind iscsi SAN Software: Installing StarWind on Windows Server 2008 R2 Server Core

USING STUFFIT DELUXE THE STUFFIT START PAGE CREATING ARCHIVES (COMPRESSED FILES)

Troubleshooting Guide

Code::Block manual. for CS101x course. Department of Computer Science and Engineering Indian Institute of Technology - Bombay Mumbai

Release Notes OPC-Server V3 Alarm Event for High Availability

Enhanced Reporting Software Monitor USER MANUAL

Tutorial: Packaging your server build

Haworth DesignIT TUTORIAL

Version 7.5 Backup and Recovery Guide

Web servers and WebSphere Portal

Android Environment SDK

PaperStream Connect. Setup Guide. Version Copyright Fujitsu

SCUt ils SmartAssign Guide Solution for Microsoft System Center 2012 Service Manager

Administrator s Guide

INSTALLATION INSTRUCTIONS FOR UKSSOGATEWAY

8x8 Virtual Office Telephony Interface for Salesforce

How to Setup and Connect to an FTP Server Using FileZilla. Part I: Setting up the server

GE Intelligent Platforms. Activating Licenses Online Using a Local License Server

Athena Knowledge Base

Backup and Restore with 3 rd Party Applications

INTRODUCTION TO THE PROJECT TRACKING WEB APPLICATION

Using SSH Secure FTP Client INFORMATION TECHNOLOGY SERVICES California State University, Los Angeles Version 2.0 Fall 2008.

Eclipse installation, configuration and operation

NComputing vspace Server 8.3 for Windows. Software and Firmware Upgrade Guide. Document version 1.2

Backing up and restoring HP Systems Insight Manager 6.0 or greater data files in a Windows environment

FirstClass Synchronization Services Install Guide

Eliminate Memory Errors and Improve Program Stability

Word 2010: Mail Merge to with Attachments

Montefiore Portal Quick Reference Guide

ECLIPSE & Faircom ODBC Driver

Data Warehouse Troubleshooting Tips

INSTALLATION GUIDE. Snow License Manager Version 7.0 Release date Document date

Converting from Practice Management Classic to Practice Management Professional or Enterprise

Mapping the ITS File Server Folders to Mosaic Windows

Install the Production Treasury Root Certificate (Vista / Win 7)

Installation and Testing of NMM (Windows)

Installing Sage Accpac ERP CGA 5.6A

Illustration 1: Diagram of program function and data flow

Step-by-step installation guide for monitoring untrusted servers using Operations Manager (Part 1 of 3)

File Manager Pro User Guide. Version 3.0

RecoveryVault Express Client User Manual

Exchange Mailbox Protection

How To Restore Your Data On A Backup By Mozy (Windows) On A Pc Or Macbook Or Macintosh (Windows 2) On Your Computer Or Mac) On An Pc Or Ipad (Windows 3) On Pc Or Pc Or Micro

r-one Python Setup 1 Setup 2 Using IDLE 3 Using IDLE with your Robot ENGI 128: Introduction to Engineering Systems Fall, 2014

NAS 253 Introduction to Backup Plan

FTP, IIS, and Firewall Reference and Troubleshooting

WA2262 Applied Data Science and Big Data Analytics Boot Camp for Business Analysts. Classroom Setup Guide. Web Age Solutions Inc.

Transcription:

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

Introduction R is an open source statistical software R provides functions to perform statistical operations o Classical (regression, logistic regression, ANOVA, etc) o Modern (neural networks, bootstrap, genomic selection, etc) Can be easily extended by make new packages

To install an R package, use function install.packages() For example, to fit a mixed model, we could use function mixed.solve(). It requires package rrblup.

Steps to Build an R package Step 1. Prepare your functions Step 2. Build the structure of the package using package.skeleton() Step 3. Edit DESCRIPTION File Step 4. Edit the help File Step 5. Preparation for Windows Users (RTools) Step 6. Build and install the R package Step 7. Check the R package Step 8. Add functions and data to a package

Build an R Package -- Step 1. Prepare your functions Before you write your functions, clear the working space using rm(list=ls()). Write your function. Load all the data you want to include in the package. Set working directory to the position containing the.r file.

Build an R Package -- Step 2. package.skeleton() Run package.skeleton(name, list). For example: package.skeleton(name="cum", list=c("my.cumsumprod", "xvec.example", "output.example") Or, package.skeleton(name= cum", code_files="cumsumprod.r") A new folder cum is built. If just run package.skeleton(), then anrpackage will be built.

Step 2 (Cont.) Inside cum / anrpackage you many find several folders: o R: contains R code files o data: contains data files o man: contains documentation files (.Rd) o You may also have src folder, if your function contains C, C++, or FORTRAN source. o Other files: tests, exec, inst, etc.

Step 2 (Cont.) also some files. o Read-and-delete-me : contain instructions for following steps. * Edit the help file skeletons in 'man', possibly combining help files for multiple functions. * Edit the exports in 'NAMESPACE', and add necessary imports. * Put any C/C++/Fortran code in 'src'. * If you have compiled code, add a usedynlib() directive to 'NAMESPACE'. * Run R CMD build to build the package tarball. * Run R CMD check to check the package tarball. Read "Writing R Extensions" for more information. o DESCRIPTION: manual file for the users. o NAMESPACE

Build an R Package -- Step 3. Edit DESCRIPTION File Package: cum -- name of the package Type: Package Title: What the package does (short line) -- contains no more than 65 characters Version: 1.0 -- a sequence of non-negative integers, like: 1.0.2, 1-0-2 Date: 2013-02-27 -- Date that the package was created. Today s date by default Author: Who wrote it -- all the authors, no limit Maintainer: Who to complain to yourfault@somewhere.net -- one name and an email address Description: More about what it does (maybe more than one line) -- Description of the package, no length limit License: What license is it under? -- Usually GPL-2 (GNU General Public License Version 2), which is good for CRAN / Bioconductor. Check Writing R Extensions for all license abbreviations.

Build an R Package -- Step 4. Edit the help File Fill the content in each category Delete the comments or instructions. Change the default content Do this for each.rd file in man folder.

Build an R Package -- Step 5. Preparation for Windows Users Download and install Rtools. http://cran.rproject.org/bin/windows/rtools/ Attention! Check the checkbox to update the current PATH.

Step 5 (Cont.) Change the PATH in Control Panel. Click System, then Advanced system settings. Click the Advanced tap in the prompt window. Then click the Environment Variables. In PATH, click Edit C:\Windows\System64\;c:\Rtools\bin;c:\Rtools\gcc- 4.6.3\bin;C:\Program Files\R\R- 2.15.1\bin\x64;c:\Rtools\perl\bin;c:\Rtools\MinGW\bi n;c:\r\bin;c:\rtools\mingw;c:\perl\bin;c:\program Files\MiKTex 2.6\miktex\bin;C:\Program Files (x86)\ssh Communications Security\SSH Secure Shell

Build an R Package -- Step 6. Build and install the R package In search box, type command prompt In command prompt, change directory to the place that contains the R package Build R package using R CMD build pkgname. For example I use R CMD build cum. A tar.gz file is built under the working directory.

Step 6 (Cont.) Install the R package using R CMD INSTALL pkgname. Here I use R CMD INSTALL cum_1.0.tar.gz. If any error occurs, check the.rd file. Then rerun R CMD build, R CMD INSTALL.

Build an R Package -- Step 7. Check the R package Install Miktex / (Mactex) package inconsolata using mpm --verbose --install inconsolata. Check the R package using R CMD check pkgname. I use R CMD check cum. In R environment, type library(pkgname). For example, library(cum). You can type?cum?my.cumsumprod?xvec.example?output.example

Build an R Package -- Step 8. Add functions and data to a package Change the working directory to the folder that contains your new functions and/or data. Copy the functions into working space. Run prompt() to the new function, i.e., prompt(cumadd). Now you have a help file for cumadd. Edit the.rd help file. Move the.r file and the.rd file to the package folder. Put the.r file in the R folder. Put the.rd file in the man folder.

Step 8 (Cont.) Read the data file into the working space. Save the data as an.rda file. Create the help file using prompt() function. Edit the.rd help file. Move the.rda file and the.rd file to the package folder. The.rda file goes to the data folder. The.Rd file goes to the man folder.

Step 8 (Cont.) Build and install the package again. o R CMD build cum o R CMD INSTALL cum_1.0.tar.gz o R CMD check cum In R console, type library(cum)?cum?my.cumsumprod?xvec.example?output.example?yvec?cumadd

Questions?

Thank you!