File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -289,6 +289,21 @@ for(i in seq_len(nrow(site_rn_table))) {
289289 # Transfer good values into gap-fill column
290290 nagf <- is.na(dat_gf$Value_MAC)
291291 dat_gf$Value_MAC[nagf] <- dat_gf$Value[nagf]
292+
293+ # MAC values are not allowed to drift outside of
294+ # the limits defined in variables_metadata.csv
295+ rni <- which(rn == vmd_combined$research_name)
296+ if(length(rni) == 1) { # i.e., if research name exists in table
297+ lb <- vmd_combined$low_bound[rni]
298+ if(!is.na(lb)) { # if a low bound is defined, truncate to it
299+ dat_gf$Value_MAC[dat_gf$Value_MAC < lb] <- lb
300+ }
301+ hb <- vmd_combined$high_bound[rni]
302+ if(!is.na(hb)) { # if a high bound is defined, truncate to it
303+ dat_gf$Value_MAC[dat_gf$Value_MAC > hb] <- hb
304+ }
305+ }
306+
292307 message("\tGap filled ",
293308 sum(is.na(dat_gf$Value)) - sum(is.na(dat_gf$Value_MAC)),
294309 " values in ", these_files$filename[j])
You can’t perform that action at this time.
0 commit comments