Skip to contents

Fill missing point source data with annual average

Usage

util_ps_fillmis(dat)

Arguments

dat

data frame from raw entity data as data.frame

Value

Input data frame as is if no missing values, otherwise missing data filled as described above.

Details

Missing concentration data are replaced with the average for the outfall in a given year. All flow data are also floored at zero. Rows with missing flow data are assigned 0 for all data. Rows with zero flow are assigned concentration of zero.

Examples

pth <- system.file('extdata/ps_dom_hillsco_falkenburg_2019.txt', package = 'tbeploads')
dat <- read.table(pth, skip = 0, sep = '\t', header = TRUE)
dat <- util_ps_checkuni(dat)
util_ps_fillmis(dat)
#>    Year Month outfall flow_mgd   tn_mgl    tp_mgl   tss_mgl   bod_mgl
#> 1  2019     1   D-001 5.296512 1.756881 0.2001634 0.4167875 0.8280425
#> 2  2019     2   D-001 2.696663 2.120932 0.2656919 0.5553969 1.5441635
#> 3  2019     3   D-001 5.689358 2.158781 0.2425811 0.3740764 1.3241451
#> 4  2019     4   D-001 4.749738 2.054544 0.3550630 0.3821190 1.2910567
#> 5  2019     5   D-001 4.396303 2.105568 0.2370389 0.3274173 1.3266714
#> 6  2019     6   D-001 5.838083 1.931209 0.2070870 0.5313604 1.3973229
#> 7  2019     7   D-001 5.194401 2.164595 0.3276313 0.3039208 1.1665574
#> 8  2019     8   D-001 3.346228 2.259220 0.2472752 0.2890792 1.2809236
#> 9  2019     9   D-001 4.748794 1.974068 0.1277325 0.6515675 1.1685260
#> 10 2019    10   D-001 6.461638 1.708387 0.1556450 0.2632500 1.3609233
#> 11 2019    11   D-001 4.240126 1.692041 0.2045273 0.3768561 1.0848231
#> 12 2019    12   D-001 4.010090 2.204548 0.1839178 0.4708175 1.6361168
#> 13 2019     1   R-001 3.698012 2.310801 0.2337734 0.3704153 1.6188011
#> 14 2019     2   R-001 3.180484 1.840923 0.2520314 0.1775579 1.8374191
#> 15 2019     3   R-001 2.761142 2.143444 0.1868349 0.3195870 1.6904981
#> 16 2019     4   R-001 5.189126 2.118240 0.2528620 0.5491718 1.4536160
#> 17 2019     5   R-001 4.454835 1.455411 0.2666154 0.3321027 1.7107790
#> 18 2019     6   R-001 6.892169 2.038263 0.3230197 0.3735168 1.2470248
#> 19 2019     7   R-001 4.239362 1.645825 0.2404983 0.3679821 1.0699091
#> 20 2019     8   R-001 6.473536 2.181010 0.2483830 0.3191815 1.2001535
#> 21 2019     9   R-001 4.167933 2.063323 0.1998192 0.3823141 1.7882855
#> 22 2019    10   R-001 3.516200 1.992785 0.2163667 0.4136695 1.2712782
#> 23 2019    11   R-001 5.407001 2.210327 0.2491462 0.3610934 1.4497958
#> 24 2019    12   R-001 5.236846 1.895703 0.1697065 0.4747824 1.8571717