forked from NOAA-EDAB/ecodata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
137 lines (101 loc) · 5.3 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# ecodata <img src="https://github.com/NOAA-EDAB/ecodata/blob/master/ecodata_logo.png" align="right" width="120" />
<!-- badges: start -->
![gitleaks](https://github.com/NOAA-EDAB/ecodata/workflows/gitleaks/badge.svg)
<!-- badges: end -->
## Overview
`ecodata` is an R data package developed by the Ecosystems Dynamics and Assessment Branch of the Northeast Fisheries Science Center
for use in State of the Ecosystem (SOE) reporting. SOE reports are high-level overviews of ecosystem indicator status and trends occurring
on the Northeast Continental Shelf. Unless otherwise stated, data are representative of specific Ecological Production Units (EPUs), referring to
the Mid-Atlantic Bight (MAB), Georges Bank (GB), Gulf of Maine (GOM), and Scotian Shelf (SS). SOE reports are developed for US Fishery
Management Councils (FMCs), and therefore indicator data for Scotian Shelf are included when available, but this is not always the case.
### Please consult the [technical documentation](https://noaa-edab.github.io/tech-doc/) of SOE indicators before using data sets.
## Using this package
1. Use the command `remotes::install_github("noaa-edab/ecodata",build_vignettes=TRUE)` to install the package.
2. Load the package into your environment with `library(ecodata)`
3. Further information about the `ecodata` package can be found [here](https://noaa-edab.github.io/ecodata/).
## Loading data sets
1. All derived data sets are available once the package has been loaded into the environment. View available data sets using the syntax `ecodata::...`
<p align="center" width="645">
<img src="https://raw.githubusercontent.com/NOAA-EDAB/ecodata/master/ecodata1.gif">
</p>
## Using geom_gls()
Also included in this package is a "geom" extension of `ggplot2` for assessing trends in time series. This function fits four trend models to each
series, uses AICc to select the best model fit, and then implements a likelihood-ratio test to determine if a trend is present. If a significant
trend is present (*P* < 0.05), then the trend line is plotted with the series. By default, a purple line color is assigned to negative trends and orange to positive trends. More detailed information about this method is available
[here](https://noaa-edab.github.io/tech-doc/trend-analysis.html).
`geom_gls()` follows the same rules as other `ggplot` stats/geoms. For example,
```
m <- 0.1
x <- 1:30
y <- m*x + rnorm(30, sd = 0.35)
data <- data.frame(x = x,
y = y)
#Plot series with trend
ggplot2::ggplot(data = data,aes(x = x, y = y)) +
geom_line() +
geom_gls()
```
produces
```{r neusfig, echo=F}
knitr::include_graphics(path="https://raw.githubusercontent.com/NOAA-EDAB/ecodata/master/docs/images/geom_gls.png")
```
This repository is a scientific product and is not official communication of the National Oceanic and Atmospheric Administration, or the United States Department of Commerce. All NOAA GitHub project code is provided on an ‘as is’ basis and the user assumes responsibility for its use. Any claims against the Department of Commerce or Department of Commerce bureaus stemming from the use of this 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.
## Build documentation
Organize [Reference](https://noaa-edab.github.io/ecodata/reference/index.html) by datasets and functions in `inst/_pkgdown.yml` and update using:
```{r, eval=F}
update_datasets_reference <- function(){
library(here)
library(dplyr)
library(yaml)
yml <- here("inst/_pkgdown.yml")
lst <- read_yaml(yml)
# listviewer::jsonedit(lst)
# inject reference to datasets
datasets <- data(package="ecodata") %>% .$results %>% .[, "Item"]
lst$reference <- list(
title = "Datasets",
contents = datasets)
write_yaml(lst, yml)
}
# build just Reference index
pkgdown::build_reference_index()
# build whole documentation website into docs/*
pkgdown::build_site()
```
Note that when building, you'll get alerted if datasets are missing or not included, eg:
```
> pkgdown::build_reference_index()
Writing 'reference/index.html'
Warning messages:
1: In '_pkgdown.yml', topic must be a known topic name or alias
x Not '`heatwave_year`'
2: In '_pkgdown.yml', topic must be a known topic name or alias
x Not '`seasonal_sst_anom_gridded`'
3: In '_pkgdown.yml', topic must be a known topic name or alias
x Not '`wind`'
4: Topics missing from index:
* ecodata
* seasonal_sst_anomaly_gridded
* soe
```
Aside: get all plot chunks mentioning given dataset for Uploader:
```{r, eval=F}
dataset <- "chl_pp"
res <- system(glue::glue("grep ecodata::{dataset} chunk-scripts/*", intern = T))
# todo: get just filenames
res
```