Whereas the variable-wide format returned by most Argo read and load functions are useful, some processing and plotting algorithms need data in a variable-long form, where the variable name is assigned to a column whose value is used to identify the measurement represented by each row.

argo_pivot_longer(tbl, id_cols)

Arguments

tbl

An Argo table with paired value/qc/adjusted columns, likely from argo_prof_levels() or argo_traj_measurement().

id_cols

A vector of column names used to identify each row in the output using dplyr::select() syntax.

Value

A tibble::tibble() with columns id_cols, variable, value, value_qc, value_adjusted, value_adjusted_qc, and value_adjusted_error.

Examples

library(dplyr, warn.conflicts = FALSE)

with_argo_example_cache({
  argo_prof_levels("dac/csio/2902746/profiles/BR2902746_001.nc") %>%
    argo_pivot_longer(id_cols = c(file, n_prof, pres))
})
#> Extracting from 1 file
#> # A tibble: 404 × 9
#>    file     n_prof  pres variable value value_qc value_adjusted value_adjusted_…
#>    <chr>     <int> <dbl> <chr>    <dbl> <chr>             <dbl> <chr>           
#>  1 csio/29…      1 0.200 doxy      188. 3                  197. 1               
#>  2 csio/29…      1 0.900 doxy      188. 3                  196. 1               
#>  3 csio/29…      1 1.90  doxy      188. 3                  197. 1               
#>  4 csio/29…      1 2.90  doxy      190. 3                  199. 1               
#>  5 csio/29…      1 4     doxy      190. 3                  199. 1               
#>  6 csio/29…      1 5     doxy      190. 3                  199. 1               
#>  7 csio/29…      1 6     doxy      190. 3                  199. 1               
#>  8 csio/29…      1 7.10  doxy      191. 3                  200. 1               
#>  9 csio/29…      1 8.20  doxy      191. 3                  200. 1               
#> 10 csio/29…      1 9.30  doxy      191. 3                  200. 1               
#> # … with 394 more rows, and 1 more variable: value_adjusted_error <dbl>