Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
eeholmes committed Jul 15, 2021
1 parent 5ab2425 commit 623a9bc
Show file tree
Hide file tree
Showing 27 changed files with 360 additions and 676 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
^.*\.Rproj$
^\.Rproj\.user$
Readme.Rmd
^_pkgdown\.yml$
^docs$
^pkgdown$
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# Session Data files
.RData
*.Rproj

# User-specific files
.Ruserdata
Expand Down Expand Up @@ -37,3 +38,5 @@ vignettes/*.pdf

# R Environment Variables
.Renviron
inst/doc
docs
20 changes: 20 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Package: pkgdownTemplate
Title: pkgdown Template Package
Date: 2021-07-04
Version: 1.0
Authors@R: person("Holmes", "Elizabeth", , "[email protected]", role = c("aut", "cre"))
Maintainer: Elizabeth Holmes <[email protected]>
URL: https://RWorkflow-Workshop-2021.github.io/pkgdown-template, https://github.com/RWorkflow-Workshop-2021/pkgdown-template
BugReports: https://github.com/RWorkflow-Workshop-2021/pkgdown-template/issues
Description: This is a template package for a NMFS branded R package with a pkgdown website.
Depends: R (>= 4.0.0)
Suggests:
rmarkdown,
knitr
Imports: stats, graphics
License: GPL-3 + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
Roxygen: list(markdown = TRUE)
VignetteBuilder: knitr
682 changes: 8 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(samplefunction)
export(sampleplot)
import(graphics)
import(stats)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# pkgdownTemplate

# Version 1.0

This is a basic template with NMFS branding. It has NMFS palette and the NMFS footer, license, and **pkgdown** structure.
3 changes: 3 additions & 0 deletions R/import_packages.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#' @import stats
#' @import graphics
NULL
16 changes: 16 additions & 0 deletions R/samplefunction.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' Sample Function Title
#'
#' This part is the description. It can be as long as you want but usually is one paragraph.
#'
#' @param x This is a required argument and has no default value.
#' @param y Has a default value of 10.
#' @param z Although this looks like it is a default string, the function `match.arg()` is
#' 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.
#' @return A string with the values.
#' @examples
#' samplefunction(1)
#' @export
samplefunction <- function(x, y=10, z=c("yellow", "red", "green")){
z <- match.arg(z)
return(paste(x, y, z))
}
18 changes: 18 additions & 0 deletions R/sampleplot.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' Sample plot
#'
#' This shows how you need to use `::` with all your functions that are not in base R.
#'
#' @param x The x variables.
#' @param y The y response values.
#' @return the coefficient of the linear regression
#' @examples
#' x <- 1:10
#' y <- 10+3*x + stats::rnorm(10, 0, 10)
#' sampleplot(x, y)
#' @export
sampleplot <- function(x, y){
the.lm <- stats::lm(y ~ x)
plot(x, y)
graphics::abline(the.lm)
return(coef(the.lm))
}
61 changes: 61 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
output:
md_document:
variant: gfm
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

# pkgdown template <img src="man/figures/logo.png" align="right" style="padding: 10px"/>

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.

The instructions will use the **usethis** and **pkgdown** packages. So install those.

## Step 1 Make sure the package builds

1. Clone this GitHub repository and then open the new repository (on your computer).
2. Set-up your RStudio project to use Roxygen for documentation and NAMESPACE
* Tools > Project Options... > Build Tools Click the checkbox that says "Build documentation with Roxygen".
* The Configure popup box for Roxygen will probably appear, if not click the Configure button. Check all the checkboxes.
3. On the Build tab, click Install and Restart to make sure it builds.
4. On the Build tab, click Check to make sure it passes all the checks.
5. Type the code `pkgdown::build_site()` and make sure the **pkgdown** building works.

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.

## Step 2 Customize your package

1. Edit the DESCRIPTION file (change Title, Description, urls for repo, Authors)
2. Add any required packages to Depends (or Imports* or Suggests*).
3. Edit the Readme.Rmd file.
4. Add your functions to the R folder. There are some template functions there already.
5. Don't touch the man folder. Roxygen2 will make your Rd files.

## Step 3 Make some vignettes (optional)

Vignettes are longform examples and are Rmd files in the `vignettes` folder. Easiest way to start a new vignette is `usethis::use_vignette("vignettename")`.

## Step 4 Customize your **pkgdown** site and build

pkgdown::build_favicon

<!-- Do not edit below. This adds the Disclaimer and NMFS footer. -->

****

```{r add-disclaimer, echo=FALSE, results='asis'}
url <- "https://raw.githubusercontent.com/nmfs-fish-tools/Resources/master/Disclaimer.md"
childtext <- readLines(url)
cat(childtext, sep="\n")
```

****

```{r footer, echo=FALSE, results='asis'}
url <- "https://raw.githubusercontent.com/nmfs-fish-tools/Resources/master/footer.md"
childtext <- readLines(url)
cat(childtext, sep="\n")
```


81 changes: 79 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,79 @@
# pkgdown-template
Clone this repo to create a NMFS branded pkgdown website
<!-- README.md is generated from README.Rmd. Please edit that file -->

# pkgdown template <img src="man/figures/logo.png" align="right" style="padding: 10px"/>

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.

The instructions will use the **usethis** and **pkgdown** packages. So
install those.

## Step 1 Make sure the package builds

1. Clone this GitHub repository and then open the new repository (on
your computer).
2. Set-up your RStudio project to use Roxygen for documentation and
NAMESPACE

- Tools &gt; Project Options… &gt; Build Tools Click the checkbox that
says “Build documentation with Roxygen”.
- The Configure popup box for Roxygen will probably appear, if not
click the Configure button. Check all the checkboxes.

1. On the Build tab, click Install and Restart to make sure it builds.
2. On the Build tab, click Check to make sure it passes all the checks.
3. Type the code `pkgdown::build_site()` and make sure the **pkgdown**
building works.

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.

## Step 2 Customize your package

1. Edit the DESCRIPTION file (change Title, Description, urls for repo,
Authors)
2. Add any required packages to Depends (or Imports\* or Suggests\*).
3. Edit the Readme.Rmd file.
4. Add your functions to the R folder. There are some template
functions there already.
5. Don’t touch the man folder. Roxygen2 will make your Rd files.

## Step 3 Make some vignettes (optional)

Vignettes are longform examples and are Rmd files in the `vignettes`
folder. Easiest way to start a new vignette is
`usethis::use_vignette("vignettename")`.

## Step 4 Customize your **pkgdown** site and build

pkgdown::build\_favicon

<!-- Do not edit below. This adds the Disclaimer and NMFS footer. -->

------------------------------------------------------------------------

## Disclaimer

The United States Department of Commerce (DOC) GitHub project code is
provided on an ‘as is’ basis and the user assumes responsibility for its
use. DOC has relinquished control of the information and no longer has
responsibility to protect the integrity, confidentiality, or
availability of the information. Any claims against the Department of
Commerce stemming from the use of its GitHub project will be governed by
all applicable Federal law. Any reference to specific commercial
products, processes, or services by service mark, trademark,
manufacturer, or otherwise, does not constitute or imply their
endorsement, recommendation or favoring by the Department of Commerce.
The Department of Commerce seal and logo, or the seal and logo of a DOC
bureau, shall not be used in any manner to imply endorsement of any
commercial product or activity by DOC or the United States Government.”

------------------------------------------------------------------------

<img src="https://raw.githubusercontent.com/nmfs-general-modeling-tools/nmfspalette/main/man/figures/noaa-fisheries-rgb-2line-horizontal-small.png" height="75" alt="NOAA Fisheries">

[U.S. Department of Commerce](https://www.commerce.gov/) \| [National
Oceanographic and Atmospheric Administration](https://www.noaa.gov) \|
[NOAA Fisheries](https://www.fisheries.noaa.gov/)
Binary file added man/figures/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions man/samplefunction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/sampleplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
navbar:
structure:
left:
- home
- reference
- sourcecode
- issue
- articles
- documents
- news
right: github

components:
home:
icon: fas fa-home fa-lg
href: index.html

reference:
text: Functions
icon: far fa-file-code fa-lg
href: reference/index.html

sourcecode:
text: Source Code
icon: fab fa-github fa-lg
href: https://github.com/RWorkflow-Workshop-2021/pkgdown-template

issue:
text: Issues
icon: fas fa-question-circle fa-lg
href: https://github.com/RWorkflow-Workshop-2021/pkgdown-template/issues/

articles:
text: Vignettes
icon: fas fa-file-contract fa-lg
href: articles/index.html

documents:
text: References
icon: fas fa-book fa-lg
menu:
- text: Scoping Document
href: Scoping.pdf
- text: Background Page
href: Article.html

reference:
- title: Plot functions
contents:
- contains("plot")
- title: Function functions
contents:
- contains("function")

news:
releases:
- text: "Version 1.0"
href: https://github.com/RWorkflow-Workshop-2021/pkgdown-template/releases/tag/v1.0

1 change: 1 addition & 0 deletions pkgdown/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url("https://nmfs-general-modeling-tools.github.io/nmfspalette/extra.css");
Binary file added pkgdown/favicon/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions vignettes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.html
*.R
24 changes: 24 additions & 0 deletions vignettes/samplevignette.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "samplevignette"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{samplevignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---

```{r setup}
library(pkgdownTemplate)
```

Here you can show uses worked up examples for your package. The easiest way to make a new package is to use `usethis::use_vignette("nameofvignette")`.

## Let's make a plot!

```{r fig.align="center"}
require(stats)
x <- runif(10)
y <- 10 + 3*x + rnorm(10)
sampleplot(x, y)
title(samplefunction("x versus y", y="10 vals", z="green"))
```

0 comments on commit 623a9bc

Please sign in to comment.