chkinp: Check input taxonomy and site data

Description Usage Arguments Details Value See Also Examples

View source: R/chkinp.R

Description

Check input taxonomy and site data for required information

Usage

1
chkinp(taxain, sitein, getval = FALSE)

Arguments

taxain

data.frame for input taxonomy data

sitein

data.frame for input site data

getval

logical to return a vector of values not satisfied by checks, useful for data prep

Details

The following are checked:

Value

The original data with only relevant columns are returned if all checks are met, including a new column for SampleID (see getids). An error message is returned if the datasets do not meet requirements or a vector of values that caused the error if getval = TRUE. Site data will include only those sites in the taxonomic data.

See Also

getids

Examples

 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
# all checks passed, data returned with SampleID
chkinp(demo_algae_tax, demo_algae_sitedata)

# errors
## Not run: 
# missing columns in taxa data
tmp <- demo_algae_tax[, 1, drop = FALSE]
chkinp(tmp, demo_algae_sitedata)
chkinp(tmp, demo_algae_sitedata, getval = TRUE)

# missing columns in site data
tmp <- demo_algae_sitedata[, 1, drop = FALSE]
chkinp(demo_algae_tax, tmp)
chkinp(demo_algae_tax, tmp, getval = TRUE)

# site data not found for taxonomic site
tmp <- demo_algae_sitedata[-1, ]
chkinp(demo_algae_tax, tmp)
chkinp(demo_algae_tax, tmp, getval = TRUE)

# incorrect taxonomy
tmp <- demo_algae_tax
tmp[1, 'FinalID'] <- 'asdf'
chkinp(tmp, demo_algae_sitedata)
chkinp(tmp, demo_algae_sitedata, getval = TRUE)

# missing diatom data at sites
tmp <- merge(demo_algae_tax, STE, all.x = T) %>%
  filter(!Class %in% 'Bacillariophyceae')
chkinp(tmp, demo_algae_sitedata)
chkinp(tmp, demo_algae_sitedata, getval = TRUE)

# missing abundance data for diatoms
tmp <- demo_algae_tax
tmp$BAResult <- NA
chkinp(tmp, demo_algae_sitedata)
chkinp(tmp, demo_algae_sitedata, getval = TRUE)

# missing environmental data
tmp <- demo_algae_sitedata
tmp$SITE_ELEV <- NA
tmp$AREA_SQKM <- NA
chkinp(demo_algae_tax, tmp)
chkinp(demo_algae_tax, tmp, getval = TRUE)

## End(Not run)

SCCWRP/ASCI documentation built on Jan. 12, 2018, 6:33 p.m.