This document outlines the steps to prepare and submit an R package to CRAN, including:
1) Preparing R code and creating package files using package.skeleton
2) Modifying files like DESCRIPTION and .Rd files
3) Installing tools, building and checking the package
4) Submitting the package to CRAN after passing checks with no warnings
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
Preparing R code for CRAN submission
1. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Preparing and submitting a package to CRAN
Adwave
Jean Sanderson
Sheffield R Users Group
16 June 2015
Preparing and submitting a package to CRAN
2. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Adwave
Work with Bioinformatics Group at Massey University
Wavelet analysis of genomic data to reconstruct population ancestry
Related method released software as set of R functions
http://bioinf.eva.mpg.de/download/StepPCO/
Reconstructing Past Admixture Processes from Local Genomic Ancestry
Using Wavelet Transformation, Genetics (available as early online)
Preparing and submitting a package to CRAN
3. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Steps to creating R package
1 Prepare R code
2 Create package files
3 Build package
Linux
Windows
4 Submit to CRAN
Preparing and submitting a package to CRAN
4. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Preparing the R code
adwave contains:
3 functions
signal
wavesum
plotsignal
An example data set, admix
Downsampled version of example in the paper so that examples run quickly
Code that you plan on sharing takes a bit more work
Foolproof code (input checks etc)
Think about nice names for functions, output etc
Preparing and submitting a package to CRAN
5. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
package.skeleton
modifying files
adding dependencies
Creating package using package.skeleton
Open R and source R code and data
Use package.skeleton
> ls()
[1] "admix" "plotsignal" "signal" "wavesum"
> package.skeleton(name="adwave")
Creating directories ...
Creating DESCRIPTION ...
Creating NAMESPACE ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in ’./adwave/Read-and-delete-me’.
Preparing and submitting a package to CRAN
6. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
package.skeleton
modifying files
adding dependencies
Creating package using package.skeleton
The following folders and files have been created
data
- admix.RDA
man (help files)
- admix.Rd
- adwave-package.Rd
- plotsignal.Rd
- signal.Rd
- wavesum.Rd
R
- plotsignal.R
- signal.R
- wavesum.R
DESCRIPTION
NAMESPACE
Read-and-delete
Prepare the DESCRIPTION, and .Rd files in text editor
Preparing and submitting a package to CRAN
7. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
package.skeleton
modifying files
adding dependencies
DESCRIPTION
Package: adwave
Type: Package
Title: Wavelet Analysis of Genomic Data from Admixed Populations
Version: 1.0
Date: 2014-10-03
Depends: waveslim
Author: Jean Sanderson
Maintainer: Murray Cox <m.p.cox@massey.ac.nz>
Description: Implements wavelet-based approaches for describing ...
License: GPL (>=2)
}
Preparing and submitting a package to CRAN
8. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
package.skeleton
modifying files
adding dependencies
signal.Rd
name{signal}
alias{signal}
title{Compute Localized Admixture Signals}
description{Produces estimates of localized ancestry. }
usage{ signal(table, who = colnames(table), ...)}
arguments{
item{table}{matrix of genotype calls.}
item{who}{individuals to include in the analysis.}
}
details{Applies PCA to genome-wide data using ...}
references{For further details, see accompanying paper.}
author{Jean Sanderson}
seealso{code{link{wavesum}}, code{link{plotsignal}}}
examples{
# EXAMPLE 1.
# Generate the admixture signal
AdexPCA <- signal(admix$data,popA="popA",popB="popB")
}
Preparing and submitting a package to CRAN
9. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
package.skeleton
modifying files
adding dependencies
List any dependencies
adwave uses the waveslim package.
Alter the DESCRIPTION file to contain
Depends: waveslim
Alter the NAMESPACE file to contain
import(waveslim)
Preparing and submitting a package to CRAN
10. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
installing tools
compiling
Setting up the computer (windows)
Download and install tools
1 Rtools: ‘collection of resources for building packages for R under
Microsoft Window’
http://cran.us.r-project.org/bin/windows/Rtools/
2 MikTex
3 HTML help workshop
4 Extra tools? (C, C++, Fortran)
Preparing and submitting a package to CRAN
11. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
installing tools
compiling
Setting up the computer (windows)
Set PATH variable so computer knows where to locate Rtools.
C:Rtoolsbin;C:Rtoolsgcc-4.6.3bin; C:Program FilesRR-3.0.1bin;
C:Program FilesRR-3.0.1binx64;C:Rbatch;C:Program FilesCommon FilesMicrosoft SharedWindows Live;
C:Program Files (x86)Common FilesMicrosoft SharedWindows Live;C:WindowsUsystem32;
C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;
C:Program FilesIntelWiFibin;C:Program FilesCommon FilesIntelWirelessCommon;
C:Program Files (x86)IntelServicesIPT;C:Program Files (x86)Windows LiveShared;
C:Program Files (x86)MiKTeX 2.9miktexbin
Preparing and submitting a package to CRAN
12. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
installing tools
compiling
After all the hard work...
1 Place formatted files somewhere suitable e.g.
C:UsersjeanDocumentsRpackagesbuild_adwave_07102014
2 Run command prompt as administrator
Right click on icon in Start menu and ‘run as administrator’
Check that R is linked by typing ‘R’. If it runs ok then exit, otherwise.... ?
Navigate one directory up from where the package folder resides. i.e.
cd C:UsersjeanDocumentsRpackagesbuild_adwave_07102014
3 To build, type
R CMD build adwave
This produces the file adwave_1.0.tar.
Recommends using command R CMD build -- resave-data adwave
4 To check the package, type
R CMD check adwave
If it doesn’t finish successfully, go back and fix the errors (and warnings)!
Particularly important if you submit to CRAN
5 To install the package, type
R CMD INSTALL adwave
Creates folder C:UsersjeanDocumentsRwin-library3.1
Preparing and submitting a package to CRAN
13. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Submit to CRAN?
http://cran.r-project.org/submit.html
Preparing and submitting a package to CRAN
14. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Submitting the package
Attempt 1: Example took too long to run
Attempt 2: Incorrect punctuation
Third time lucky!
Make sure that the package has passed all the checks with no warnings and
you’ve followed all the formatting advice exactly.
http://cran.r-project.org/doc/manuals/r-release/R-exts.html
Preparing and submitting a package to CRAN
15. Preparing R code
Creating package files
Building and checking the package
Submitting to CRAN
Finished product
Preparing and submitting a package to CRAN