-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
360 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
Readme.Rmd | ||
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#' @import stats | ||
#' @import graphics | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 > 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. | ||
|
||
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/) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.html | ||
*.R |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | ||
``` |