├── .gitignore ├── data └── graywhales.rda ├── NAMESPACE ├── R ├── testfoo.ischaracter.r └── foo.r ├── DESCRIPTION ├── man ├── graywhales.Rd └── foo.Rd └── inst ├── CITATION └── doc └── foo.Rnw /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | package-skeleton.Rproj 6 | .Rbuildignore 7 | -------------------------------------------------------------------------------- /data/graywhales.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/package-skeleton/master/data/graywhales.rda -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | ## simple NAMESPACE 2 | ## Tell R what functions the user should be able to access after library(package) call 3 | 4 | ## export functions 5 | export( 6 | foo 7 | ) 8 | -------------------------------------------------------------------------------- /R/testfoo.ischaracter.r: -------------------------------------------------------------------------------- 1 | ############################################################################################################################ 2 | # testfoo.ischaracter() 3 | # tests if x is a character 4 | ########################################################################################################################## 5 | testfoo.ischaracter = function(x) 6 | { 7 | if(is.character(x)) return(TRUE) 8 | else return(FALSE) 9 | } 10 | -------------------------------------------------------------------------------- /R/foo.r: -------------------------------------------------------------------------------- 1 | ############################################################################################################################ 2 | # foo() 3 | # This is a test function 4 | ########################################################################################################################## 5 | foo = function(x,a) 6 | { 7 | tmp=testfoo.ischaracter(x) 8 | if(tmp) 9 | cat("Character ", x, " ", a, "\n") 10 | else 11 | cat("Not character", x, "\n") 12 | if(1==0) cat(d) 13 | } 14 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: package-skeleton 2 | Type: Package 3 | Title: Template 4 | Version: 1.0 5 | Date: 2013-7-2 6 | Depends: R (>= 2.15.0), MASS, mvtnorm, nlme 7 | Suggests: Hmisc, maps, xtable 8 | Author: Eli Holmes, NOAA, Seattle, USA 9 | Maintainer: Elizabeth Holmes - NOAA Federal 10 | Description: This is a template to show you how a package works. You can clone to make your own package. 11 | License: GPL-2 12 | LazyData: yes 13 | BuildVignettes: yes 14 | ByteCompile: TRUE 15 | -------------------------------------------------------------------------------- /man/graywhales.Rd: -------------------------------------------------------------------------------- 1 | \name{graywhales} 2 | \alias{graywhales} 3 | \docType{data} 4 | \title{ Gray Whale Data } 5 | \description{ 6 | Some data for Foo. 7 | } 8 | \usage{ 9 | data(graywhales) 10 | } 11 | \format{ 12 | The data are supplied as a matrix with years in the first column and counts in the second column. 13 | } 14 | \source{ 15 | \itemize{ 16 | \item{graywhales }{ Gerber L. R., Master D. P. D. and Kareiva P. M. (1999) Gray whales and the value of monitoring data in implementing the U.S. Endangered Species Act. Conservation Biology, 13, 1215-1219.} 17 | } 18 | } 19 | \examples{ 20 | str(graywhales) 21 | } 22 | \keyword{datasets} 23 | -------------------------------------------------------------------------------- /man/foo.Rd: -------------------------------------------------------------------------------- 1 | \name{foo} 2 | \alias{foo} 3 | \alias{foobar} 4 | \title{ Foo } 5 | \description{ 6 | foo is a simple function that shows 7 | \describe{ 8 | \item{character}{shows the character} 9 | \item{anything else}{shows that too} 10 | } 11 | More description. 12 | } 13 | \usage{ 14 | foo(x, a) 15 | } 16 | 17 | \arguments{ 18 | \item{x}{ the thing to be tested} 19 | \item{a}{ something printed } 20 | } 21 | \details{ 22 | There aren't many details for foo. 23 | } 24 | \value{ 25 | Here you describe the output of foo. 26 | } 27 | \author{ 28 | Eli Holmes, NOAA, Seattle, USA. 29 | } 30 | 31 | \seealso{ \code{\link{graywhales}} } 32 | 33 | \references{ 34 | Here you can put references. 35 | } 36 | 37 | \examples{ 38 | foo("a","b") 39 | foo(1,"a") 40 | } 41 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite the 'foo' package in publications use:") 2 | 3 | year <- sub(".*(2[[:digit:]]{3})-.*", "\\1", meta$Date, perl = TRUE) 4 | vers <- paste("R package version", meta$Version) 5 | 6 | citEntry(entry="Manual", 7 | title = "Foo: A Template", 8 | author = personList(as.person("Elizabeth Holmes")), 9 | year = year, 10 | note = vers, 11 | url = "http://cran.r-project.org/web/packages/foo/", 12 | textVersion = 13 | paste("Elizabeth Holmes, (", year, 14 | "). foo: A Template. ", 15 | vers, ".", sep="") ) 16 | 17 | citEntry(entry="Article", 18 | title = "MARSS: Multivariate autoregressive state-space models for analyzing time-series data", 19 | author = personList(as.person("Elizabeth E. Holmes"), 20 | as.person("Eric J. Ward"), 21 | as.person("Kellie Wills")), 22 | year = {2012}, 23 | journal = "The R Journal", 24 | volume = {4}, 25 | number = {1}, 26 | pages = {11--19}, 27 | 28 | textVersion = 29 | paste("Holmes, E. E., Ward, E. J. & Wills, K. (2012)", 30 | "MARSS: Multivariate Autoregressive State-space Models for Analyzing Time-series Data.", 31 | "The R Journal. 4(1):11-19") 32 | ) 33 | -------------------------------------------------------------------------------- /inst/doc/foo.Rnw: -------------------------------------------------------------------------------- 1 | %\VignetteIndexEntry{foo Guide} 2 | %\VignettePackage{foo} 3 | \documentclass[12pt]{article} 4 | \usepackage[landscape]{geometry} 5 | \usepackage{hyperref} 6 | 7 | %\input{tex/mathdefs} 8 | \usepackage{amsmath} % the standard math package 9 | %%%% bold maths symbol system: 10 | \def\AA{\mbox{$\mathbf A$}} 11 | \def\aa{\mbox{$\mathbf a$}} 12 | \def\BB{\mbox{$\mathbf B$}} 13 | \def\bb{\mbox{$\mathbf b$}} 14 | \def\CC{\mbox{$\mathbf C$}} 15 | \def\cc{\mbox{$\mathbf c$}} 16 | \def\DD{\mbox{$\mathbf D$}} 17 | \def\dd{\mbox{$\mathbf d$}} 18 | \def\EE{\mbox{$\mathbf E$}} 19 | \def\ee{\mbox{$\mathbf e$}} 20 | \def\FF{\mbox{$\mathbf F$}} 21 | \def\ff{\mbox{$\mathbf f$}} 22 | \def\gg{\mbox{$\mathbf g$}} 23 | \def\GG{\mbox{$\mathbf G$}} 24 | \def\HH{\mbox{$\mathbf H$}} 25 | \def\II{\mbox{$\mathbf I$}} 26 | \def\LL{\mbox{$\mathbf L$}} 27 | \def\MM{\mbox{$\mathbf M$}} 28 | \def\mm{\mbox{$\mathbf m$}} 29 | \def\OO{\mbox{$\mathbf O$}} 30 | \def\PP{\mbox{$\mathbf P$}} 31 | \def\pp{\mbox{$\mathbf p$}} 32 | \def\QQ{\mbox{$\mathbf Q$}} 33 | \def\qq{\mbox{$\mathbf q$}} 34 | \def\RR{\mbox{$\mathbf R$}} 35 | \def\rr{\mbox{$\mathbf r$}} 36 | \def\UU{\mbox{$\mathbf U$}} 37 | \def\uu{\mbox{$\mathbf u$}} 38 | \def\VV{\mbox{$\mathbf V$}} 39 | \def\vv{\mbox{$\mathbf v$}} 40 | \def\WW{\mbox{$\mathbf W$}} 41 | \def\ww{\mbox{$\mathbf w$}} 42 | \def\XX{\mbox{$\mathbf X$}} 43 | \def\xx{\mbox{$\mathbf x$}} 44 | \def\YY{\mbox{$\mathbf Y$}} 45 | \def\yy{\mbox{$\mathbf y$}} 46 | \def\ZZ{\mbox{$\mathbf Z$}} 47 | \def\zz{\mbox{$\mathbf z$}} 48 | \def\et{\mbox{\boldmath $\eta$}} 49 | \def\ep{\mbox{\boldmath $\epsilon$}} 50 | \def\pipi{\mbox{\boldmath $\pi$}} 51 | \def\uupsilon{\pmb{\upsilon}} 52 | \def\llambda{\pmb{\lambda}} 53 | \def\bbeta{\pmb{\beta}} 54 | \def\aalpha{\pmb{\alpha}} 55 | \def\zzeta{\pmb{\zeta}} 56 | \def\etaeta{\mbox{\boldmath $\eta$}} 57 | \def\xixi{\mbox{\boldmath $\xi$}} 58 | \def\PI{\mbox{\boldmath $\mathrm{\Pi}$}} 59 | \def\LAM{\mbox{\boldmath $\mathrm{\Lambda}$}} 60 | \def\GAM{\mbox{\boldmath $\mathrm{\Gamma}$}} 61 | \def\SI{\mbox{\boldmath $\mathrm{\Sigma}$}} 62 | \def\TH{\mbox{\boldmath $\mathrm{\Theta}$}} 63 | \def\PH{\mbox{\boldmath $\mathrm{\Phi}$}} 64 | \def\zer{\mbox{\boldmath $0$}} 65 | \def\vec{\,\textup{\textrm{vec}}} 66 | \def\var{\,\textup{\textrm{var}}} 67 | \def\cov{\,\textup{\textrm{cov}}} 68 | \def\MVN{\,\textup{\textrm{MVN}}} 69 | \def\AIC{\,\textup{\textrm{AIC}}} 70 | \def\E{\,\textup{\textrm{E}}} 71 | \def\Lik{\,\textup{\textrm{L}}} 72 | \def\N{\,\textup{\textrm{N}}} 73 | \def\R{R} 74 | 75 | \title{Foo Guide} 76 | \begin{document} 77 | \SweaveOpts{concordance=TRUE} 78 | <>= 79 | library(Foo) 80 | options(prompt=" ", continue=" ") 81 | @ 82 | \section*{Foo Quick Start Guide} 83 | Here is an equation that has nothin to do with foo: 84 | \begin{equation}\label{eqn:marss} 85 | \begin{gathered} 86 | \xx_t = \BB_t\xx_{t-1} + \uu_t + \CC_t\cc_t + \ww_t, \text{ where } \ww_t \sim \MVN(0,\QQ_t)\\ 87 | \yy_t = \ZZ_t\xx_t + \aa_t + \DD_t\dd_t + \vv_t, \text{ where } \vv_t \sim \MVN(0,\RR_t)\\ 88 | \xx_1 \sim \MVN(\pipi,\LAM) \text{ or } \xx_0 \sim \MVN(\pipi,\LAM) 89 | \end{gathered} 90 | \end{equation} 91 | $\cc$ and $\dd$ are inputs and must have no missing values. 92 | 93 | \section{Here is some foo code} 94 | Let's run foo 95 | <>= 96 | foo("dog",1) 97 | @ 98 | That was boring. 99 | <>= 100 | foo(1,1) 101 | @ 102 | <>= 103 | options(prompt="> ", continue="+ ") 104 | @ 105 | \end{document} 106 | --------------------------------------------------------------------------------