Helper function to cast data frame to wide format
to_wide(df, lab_id = FALSE, join_lt = TRUE)
df | data frame in long format |
---|---|
lab_id | logical to include lab_id. Default is FALSE. |
join_lt | logical to join the non-detect colum with analysis result. |
data(gw_data) gw_data %>% filter(param_name %in% c("Arsenic, dissolved", "Boron, dissolved")) %>% to_wide()#> # A tibble: 149 x 4 #> # Groups: location_id, sample_date [149] #> location_id sample_date `Arsenic, dissolved (u… `Boron, dissolved (m… #> <chr> <dttm> <chr> <chr> #> 1 MW-1 2007-12-20 00:00:00 "< 10" " 0.174" #> 2 MW-1 2008-02-20 00:00:00 "< 10" " 0.255" #> 3 MW-1 2008-04-24 00:00:00 "< 10" " 0.73" #> 4 MW-1 2008-06-18 00:00:00 "< 10" " 1.34" #> 5 MW-1 2008-08-26 00:00:00 " 1.7" " 1.37" #> 6 MW-1 2008-10-28 00:00:00 " 1.9" " 1.33" #> 7 MW-1 2008-12-16 00:00:00 " 1.8" " 1.13" #> 8 MW-1 2009-02-25 00:00:00 " 1.7" " 1.14" #> 9 MW-1 2009-04-29 00:00:00 " 1.3" " 1.14" #> 10 MW-1 2009-10-21 00:00:00 " 1.5" " 1.28" #> # … with 139 more rows