Skip to content

Commit 623a9bc

Browse files
committed
first commit
1 parent 5ab2425 commit 623a9bc

27 files changed

Lines changed: 360 additions & 676 deletions

.Rbuildignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
^.*\.Rproj$
2+
^\.Rproj\.user$
3+
Readme.Rmd
4+
^_pkgdown\.yml$
5+
^docs$
6+
^pkgdown$

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Session Data files
66
.RData
7+
*.Rproj
78

89
# User-specific files
910
.Ruserdata
@@ -37,3 +38,5 @@ vignettes/*.pdf
3738

3839
# R Environment Variables
3940
.Renviron
41+
inst/doc
42+
docs

DESCRIPTION

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Package: pkgdownTemplate
2+
Title: pkgdown Template Package
3+
Date: 2021-07-04
4+
Version: 1.0
5+
Authors@R: person("Holmes", "Elizabeth", , "eli.holmes@noaa.gov", role = c("aut", "cre"))
6+
Maintainer: Elizabeth Holmes <eli.holmes@noaa.gov>
7+
URL: https://RWorkflow-Workshop-2021.github.io/pkgdown-template, https://github.com/RWorkflow-Workshop-2021/pkgdown-template
8+
BugReports: https://github.com/RWorkflow-Workshop-2021/pkgdown-template/issues
9+
Description: This is a template package for a NMFS branded R package with a pkgdown website.
10+
Depends: R (>= 4.0.0)
11+
Suggests:
12+
rmarkdown,
13+
knitr
14+
Imports: stats, graphics
15+
License: GPL-3 + file LICENSE
16+
Encoding: UTF-8
17+
LazyData: true
18+
RoxygenNote: 7.1.1
19+
Roxygen: list(markdown = TRUE)
20+
VignetteBuilder: knitr

LICENSE

Lines changed: 8 additions & 674 deletions
Large diffs are not rendered by default.

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(samplefunction)
4+
export(sampleplot)
5+
import(graphics)
6+
import(stats)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# pkgdownTemplate
2+
3+
# Version 1.0
4+
5+
This is a basic template with NMFS branding. It has NMFS palette and the NMFS footer, license, and **pkgdown** structure.

R/import_packages.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#' @import stats
2+
#' @import graphics
3+
NULL

R/samplefunction.R

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#' Sample Function Title
2+
#'
3+
#' This part is the description. It can be as long as you want but usually is one paragraph.
4+
#'
5+
#' @param x This is a required argument and has no default value.
6+
#' @param y Has a default value of 10.
7+
#' @param z Although this looks like it is a default string, the function `match.arg()` is
8+
#' used to set it in the function. With `match.arg()`, the string specifies what values are allowed and it will throw an error if not one of those. The default is the first value.
9+
#' @return A string with the values.
10+
#' @examples
11+
#' samplefunction(1)
12+
#' @export
13+
samplefunction <- function(x, y=10, z=c("yellow", "red", "green")){
14+
z <- match.arg(z)
15+
return(paste(x, y, z))
16+
}

R/sampleplot.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#' Sample plot
2+
#'
3+
#' This shows how you need to use `::` with all your functions that are not in base R.
4+
#'
5+
#' @param x The x variables.
6+
#' @param y The y response values.
7+
#' @return the coefficient of the linear regression
8+
#' @examples
9+
#' x <- 1:10
10+
#' y <- 10+3*x + stats::rnorm(10, 0, 10)
11+
#' sampleplot(x, y)
12+
#' @export
13+
sampleplot <- function(x, y){
14+
the.lm <- stats::lm(y ~ x)
15+
plot(x, y)
16+
graphics::abline(the.lm)
17+
return(coef(the.lm))
18+
}

README.Rmd

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
output:
3+
md_document:
4+
variant: gfm
5+
---
6+
7+
<!-- README.md is generated from README.Rmd. Please edit that file -->
8+
9+
# pkgdown template <img src="man/figures/logo.png" align="right" style="padding: 10px"/>
10+
11+
This is a template for a NMFS branded GitHub repository, R package, and pkgdown website. It will have a NMFS palette, appropriate license and disclaimer, and a NMFS footer with logo.
12+
13+
The instructions will use the **usethis** and **pkgdown** packages. So install those.
14+
15+
## Step 1 Make sure the package builds
16+
17+
1. Clone this GitHub repository and then open the new repository (on your computer).
18+
2. Set-up your RStudio project to use Roxygen for documentation and NAMESPACE
19+
* Tools > Project Options... > Build Tools Click the checkbox that says "Build documentation with Roxygen".
20+
* The Configure popup box for Roxygen will probably appear, if not click the Configure button. Check all the checkboxes.
21+
3. On the Build tab, click Install and Restart to make sure it builds.
22+
4. On the Build tab, click Check to make sure it passes all the checks.
23+
5. Type the code `pkgdown::build_site()` and make sure the **pkgdown** building works.
24+
25+
Note steps 3 and 4 are to make sure your computer is set up to build and check packages. As long as you haven't editted the package yet, it will build and pass check.
26+
27+
## Step 2 Customize your package
28+
29+
1. Edit the DESCRIPTION file (change Title, Description, urls for repo, Authors)
30+
2. Add any required packages to Depends (or Imports* or Suggests*).
31+
3. Edit the Readme.Rmd file.
32+
4. Add your functions to the R folder. There are some template functions there already.
33+
5. Don't touch the man folder. Roxygen2 will make your Rd files.
34+
35+
## Step 3 Make some vignettes (optional)
36+
37+
Vignettes are longform examples and are Rmd files in the `vignettes` folder. Easiest way to start a new vignette is `usethis::use_vignette("vignettename")`.
38+
39+
## Step 4 Customize your **pkgdown** site and build
40+
41+
pkgdown::build_favicon
42+
43+
<!-- Do not edit below. This adds the Disclaimer and NMFS footer. -->
44+
45+
****
46+
47+
```{r add-disclaimer, echo=FALSE, results='asis'}
48+
url <- "https://raw.githubusercontent.com/nmfs-fish-tools/Resources/master/Disclaimer.md"
49+
childtext <- readLines(url)
50+
cat(childtext, sep="\n")
51+
```
52+
53+
****
54+
55+
```{r footer, echo=FALSE, results='asis'}
56+
url <- "https://raw.githubusercontent.com/nmfs-fish-tools/Resources/master/footer.md"
57+
childtext <- readLines(url)
58+
cat(childtext, sep="\n")
59+
```
60+
61+

0 commit comments

Comments
 (0)