-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContDataQC_Guide_02_Config.Rmd
101 lines (83 loc) · 3.34 KB
/
ContDataQC_Guide_02_Config.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
---
title: ContDataQC Guide 02 Config
author: "[email protected]"
date: "`r Sys.time()`"
output:
html_notebook:
toc: yes
depth: 3
toc_float: no
---
# Purpose
Example code for `ContDataQC` Guide 02 Config.
# Explanation
The `ContDataQC` package contains a “configuration” file that holds the thresholds, formats, directory names, and parameter names used in the internal workings of the package.
The user has the option of loading their own configuration file to override the defaults.
# Demo
## Vingette
```{r vignette, eval=FALSE}
library(ContDataQC)
vignette("ContDataQC_Vignette",package="ContDataQC")
```
## Copy Config File to Working Directory
Use the code below to copy from the pacakge directory "extdata" to the working directory. The code renames the file from config.ORIG.R to config.MOD.R.
```{r CopyConfig, eval=FALSE}
# copy from package to working directory
file.copy(file.path(path.package("ContDataQC"),"extdata","config.ORIG.R")
, file.path(getwd(),"config.MOD.R"))
```
Alternatively the user can get a copy from the GitHub website.
https://github.com/leppott/ContDataQC/blob/master/R/config.R
## Modify the Code
In this example change the thresholds relevant to the flat line test.
Code Line | Variable Name | Value (ORIG) | Value (MOD)
----------|---------------|--------------|------------
366 | ContData.env\$myThresh.Flat.Hi.WaterTemp | 30 | 50
367 | ContData.env\$myThresh.Flat.Lo.WaterTemp | 20 | 30
Table: Lines of code to modify in config.MOD.R
Then delete all other lines of code.
Before closing (and saving) add comment lines with name and purpose of the modification. Comment lines start with "#".
```{r OpenConfig, eval=FALSE}
# Open file so can edit
file.edit("config.MOD.R")
## after editing save before close.
```
## Using the Modified Configuration
Run the code with the default configuration.
```{r ExampleConfig_Default, eval=FALSE}
# load library
library(ContDataQC)
myDir.BASE <- getwd()
# QC Raw Data (DEFAULT config)
myData.Operation <- "QCRaw" #Selection.Operation[2]
myData.SiteID <- "test2"
myData.Type <- "AW" #Selection.Type[3]
myData.DateRange.Start <- "2013-01-01"
myData.DateRange.End <- "2014-12-31"
myDir.import <- file.path(myDir.BASE,"Data1_RAW") #Selection.SUB[1]
myDir.export <- file.path(myDir.BASE,"Data2_QC") #Selection.SUB[2]
myReport.format <- "html"
ContDataQC(myData.Operation, myData.SiteID, myData.Type, myData.DateRange.Start
, myData.DateRange.End, myDir.import, myDir.export
, fun.myReport.format=myReport.format)
```
Then re-run the same data with different thresholds for the flat line test.
```{r ExampleConfig_ModFlat, eval=FALSE}
# load library
library(ContDataQC)
myDir.BASE <- getwd()
# QC Raw Data (MODIFIED config)
myData.Operation <- "QCRaw" #Selection.Operation[2]
myData.SiteID <- "test2"
myData.Type <- "AW" #Selection.Type[3]
myData.DateRange.Start <- "2013-01-01"
myData.DateRange.End <- "2014-12-31"
myDir.import <- file.path(myDir.BASE, "Data1_RAW") #Selection.SUB[1]
myDir.export <- file.path(myDir.BASE, "Data2_QC") #Selection.SUB[2]
myReport.format <- "html"
myConfig <- "config_flat.R"
ContDataQC(myData.Operation, myData.SiteID, myData.Type, myData.DateRange.Start
, myData.DateRange.End, myDir.import, myDir.export
, fun.myConfig = myConfig
, fun.myReport.format=myReport.format)
```