chorizon <- chorizon %>%
mutate(thick = ifelse(hzdepb.r > 30, 30 - hzdept.r,
hzdepb.r - hzdept.r)) %>%
group_by(cokey) %>%
summarise(sand = round(weighted.mean(sandtotal.r, thick, na.rm = TRUE),2),
silt = round(weighted.mean(silttotal.r, thick, na.rm = TRUE),2),
clay = round(weighted.mean(claytotal.r, thick, na.rm = TRUE),2),
om = round(weighted.mean(om.r, thick, na.rm = TRUE),2),
ksat = round(weighted.mean(ksat.r, thick, na.rm = TRUE),2),
k = round(weighted.mean(kffact, thick, na.rm = TRUE),2),
cec = round(weighted.mean(cec7.r, thick, na.rm = TRUE),2),
ph = round(weighted.mean(ph1to1h2o.r, thick),2))