-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit f7a9427
Showing
75 changed files
with
3,856 additions
and
0 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,13 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
Readme.Rmd | ||
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ | ||
^\.github$ | ||
^pkgdownTemplate\.Rcheck$ | ||
^pkgdownTemplate.*\.tar\.gz$ | ||
^pkgdownTemplate.*\.tgz$ | ||
^DataProduct\.Rcheck$ | ||
^DataProduct.*\.tar\.gz$ | ||
^DataProduct.*\.tgz$ |
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 @@ | ||
*.html |
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,33 @@ | ||
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. | ||
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions | ||
# Turned of check/build of vignettes | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
pull_request: | ||
branches: | ||
- main | ||
- master | ||
|
||
name: R-CMD-check | ||
|
||
jobs: | ||
R-CMD-check: | ||
runs-on: macOS-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: r-lib/actions/setup-r@v1 | ||
- name: Install dependencies | ||
run: | | ||
install.packages(c("remotes", "rcmdcheck")) | ||
remotes::install_deps(dependencies = TRUE) | ||
shell: Rscript {0} | ||
- name: Check | ||
run: | | ||
options(crayon.enabled = TRUE) | ||
rcmdcheck::rcmdcheck(args = c("--no-manual", "--no-build-vignettes"), error_on = "error", build_args = "--no-build-vignettes") | ||
shell: Rscript {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,47 @@ | ||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
||
# Session Data files | ||
.RData | ||
*.Rproj | ||
|
||
# User-specific files | ||
.Ruserdata | ||
|
||
# Example code in package build process | ||
*-Ex.R | ||
|
||
# Output files from R CMD build | ||
/*.tar.gz | ||
|
||
# Output files from R CMD check | ||
/*.Rcheck/ | ||
|
||
# RStudio files | ||
.Rproj.user/ | ||
|
||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
|
||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
|
||
# knitr and R markdown default cache directories | ||
*_cache/ | ||
/cache/ | ||
|
||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md | ||
|
||
# R Environment Variables | ||
.Renviron | ||
inst/doc | ||
pkgdownTemplate.Rcheck/ | ||
pkgdownTemplate*.tar.gz | ||
pkgdownTemplate*.tgz | ||
DataProduct.Rcheck/ | ||
DataProduct*.tar.gz | ||
DataProduct*.tgz |
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,19 @@ | ||
Package: DataProduct | ||
Title: A NMFS Data Product | ||
Date: 2022-02-14 | ||
Version: 1.0 | ||
Authors@R: c(person("Elizabeth", "Holmes", , "[email protected]", role = c("aut", "cre")), person("Another", "Contributor", role="aut")) | ||
URL: https://rverse-tutorials.github.io/DataProduct, https://github.com/rverse-tutorials/DataProduct | ||
BugReports: https://github.com/rverse-tutorials/DataProduct/issues | ||
Description: This is an expample NMFS branded R data 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.2 | ||
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,8 @@ | ||
Software code created by U.S. Government employees is not subject to | ||
copyright in the United States (17 U.S.C. §105). The United State | ||
s/Department of Commerce reserve all rights to seek and obtain copyright | ||
protection in countries other than the United States for Software authored | ||
in its entirety by the Department of Commerce. To this end, the Department | ||
of Commerce hereby grants to Recipient a royalty-free, nonexclusive license | ||
to use, copy, and create derivative works of the Software outside of the | ||
United States. |
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,18 @@ | ||
#' @title a dataset of horsepower for different cars | ||
#' | ||
#' @description First 4 columns of the mtcars dataset. | ||
#' | ||
#' \itemize{ | ||
#' \item mpg. miles per gallon | ||
#' \item cyl. cylinders | ||
#' \item disp. displacement | ||
#' \item hp. horse poser | ||
#' } | ||
#' | ||
#' @docType data | ||
#' @name cars | ||
#' @usage data(cars) | ||
#' @references R base package. | ||
#' @format A data frame. | ||
#' @keywords datasets | ||
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 @@ | ||
#' @title sepal length for differen species of iris | ||
#' | ||
#' @description The Species and Sepal.Length from the iris data set from base R. | ||
#' | ||
#' \itemize{ | ||
#' \item Species. species | ||
#' \item Sepal.Length. sepal length | ||
#' } | ||
#' | ||
#' @docType data | ||
#' @name iris2 | ||
#' @usage data(iris2) | ||
#' @references from R base package. | ||
#' @format A data frame. | ||
#' @keywords datasets | ||
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,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,93 @@ | ||
--- | ||
output: | ||
md_document: | ||
variant: gfm | ||
--- | ||
|
||
<!-- README.md is generated from README.Rmd. Please edit that file --> | ||
|
||
# DataProduct <img src="man/figures/logo.png" align="right" style="padding: 10px"/> | ||
|
||
<!-- badges: start --> | ||
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/RVerse-Tutorials/DataProduct)](https://github.com/RVerse-Tutorials/DataProduct/releases) | ||
[![R-CMD-check](https://github.com/RVerse-Tutorials/DataProduct/workflows/R-CMD-check/badge.svg)](https://github.com/RVerse-Tutorials/DataProduct/actions/workflows/R-CMD-check.yaml) | ||
<!-- badges: end --> | ||
|
||
This is a template for a NMFS branded 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. If on RStudio Cloud, you will need to use `pkgdown::build_site(override = list(destination = "~/docs"))` to | ||
|
||
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 edited 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 | ||
|
||
1. Structure of the upper navbar. Edit `_pkgdown.yml` in the `pkddown` folder to change the look of the upper navbar. There are endless options. Find examples from other peoples' pkgdown sites. | ||
2. Update your logo and favicons. Logo is in `man/figures`. After updating run `pkgdown::build_favicon()` to remake the favicons. | ||
3. Add material to the `docs` folder as needed. See the example for the References tab in the `_pkgdown.yml`. | ||
4. Build your site with `pkgdown::build_site()`. | ||
|
||
## Step 5 Make your site live on GitHub | ||
|
||
1. Push the changes to GitHub. | ||
2. Click on Settings for the repository. | ||
3. Scroll way down to the GitHub Pages section. | ||
4. In the **Source** section, change branch to Main and folder to `docs`. There are other ways to set up GitHub Pages but this will get you started. | ||
5. I always add my GitHub Pages URL to the repo description (on right when on your main repo page). | ||
|
||
## NMFS Branding | ||
|
||
This template has the following branding elements. | ||
|
||
1. `extra.css` in the `pkgdown` folder sources the **nmfspalette** css. This get you the colors. | ||
2. The `Readme.Rmd` file sources the NMFS Disclaimer and footer with NMFS logo from the [FIT Resources](https://github.com/nmfs-fish-tools/Resources). | ||
3. The LICENSE is set to that used by [FIT packages](https://github.com/nmfs-fish-tools). | ||
|
||
## GitHub Actions and Badges | ||
|
||
In the `.github` folder is just one action, to run R CMD check on the package. | ||
|
||
## Readme File | ||
|
||
**pkgdown** uses `Readme.md` but to pull in the Disclaimer and footer from FIT, you need a Rmd file. When you update the `Readme.Rmd` file, **you need to remember to knit the file** to update `Readme.md`. | ||
|
||
<!-- 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") | ||
``` | ||
|
||
|
Oops, something went wrong.