-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinCatchAnalysis_2_HelperFunctions.qmd
103 lines (62 loc) · 2.94 KB
/
FinCatchAnalysis_2_HelperFunctions.qmd
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
# Helpers
There are a number of helper functions available in the FinCatch Analysis package.
## Dplyr Verbs
### AddStockCategory
This function works as a dplyr verb and adds a column containing a factor of stock-length categories from Gabelhouse's 5-cell model. The function takes the name of the column containing the species code, the column containing the fish length (in mm), and a reference to the data object for the analysis (needed to retrieve species code and stock length values). The function defaults to full group names as factor labels; use abbrieviations=TRUE to use category abbrieviations instead.
Example:
``` r
some_data %>%
AddStockCategory(sppCode, fishLen, someDataObject, useAbbreviations = TRUE)
```
### AddWrParameters
This dplyr verb has yet to be implented
### AddAgeIntercept
This dplyr verb has yet to be implemented
## Functions
### weighted.se.mean
This function calculates standard error around a weighted mean. The function assumes a weighted mean calculated by the "weighted.mean()" function in the stats package of R and accepts the same arguements.
Example:
``` r
some_data=data.frame(xValue=c(3,4,6,3,2,3),
xWeights=c(0.2, 0.2, 0.3, 0.1, 0.1, 0.1))
some_data %>%
mutate(myWeightedMean=weighted.mean(xValue, xWeights, na.rm=TRUE),
myWeightedMeanSE=weighted.se.mean(xValue, xWeights, na.rm=TRUE))
```
### fca_getAnalysisFunctions
This function returns a list and description of the analysis functions available in the FinCatchAnalysis package.
Example:
``` r
fca_getAnalysisFunctions()
```
## Labelers
### fc_labeler_Survey
This function creates a label for each survey to be used in outputs such as reports and plots. The arguments are a vector of surveyUid values and a reference to the analysis data object. The label returned is structured like:
> Title1 (WB=5110 \| Method=21 \| Year=2022 \| Season=Spring)
Example:
``` r
some_data %>%
mutate(surveyLabel=fc_labeler_Survey(surveyUid, aDataObject))
```
### fc_labeler_fishSample
This function creates a label for each fish sample to be used in outputs such as reports and plots. The arguments are a vector of surveyUid values and a dataframe of fish samples in the analysis taken from the data object. The label returned is structured like:
> WB=2832 \| Method=45 \| 2022-03-11 \| Station=627
Example:
``` r
some_data %>%
mutate(sampleLabel=fc_labeler_fishSample(surveyUid, aDataObject$get_data_samplesFish))
```
### fc_labeler_wqSample
This function creates a label for each fish sample to be used in outputs such as reports and plots. The arguments are a vector of surveyUid values and a dataframe of fish samples in the analysis taken from the data object. The label returned is structured like:
> WB=2832 \| 2022-03-11 \| Station=627
Example:
``` r
some_data %>%
mutate(sampleLabel=fc_labeler_wqSample(surveyUid, aDataObject$get_data_samplesWq))
```
### fc_matchCodes
www
### fc_createCodeLabel
www
### fc_createCodeLabelReversed
www