Skip to contents

This is a convenience wrapper arount cut() and dplyr::mutate(). It creates a state column dividing a light column into recommended levels by Brown et al. (2022). Cuts can be adjusted or extended with vector_cuts and vector_labels

Usage

Brown_cut(
  dataset,
  MEDI.colname = MEDI,
  New.state.colname = state,
  vector_cuts = c(-Inf, 1, 10, 250, Inf),
  vector_labels = c("≤1lx", "≤10lx", NA, "≥250lx"),
  overwrite = TRUE
)

Arguments

dataset

A light exposure dataframe

MEDI.colname

The colname containing melanopic EDI values (or, alternatively, Illuminance). Defaults to MEDI. Expects a symbol.

New.state.colname

Name of the new column that will contain the cut data. Expects a symbol.

vector_cuts

Numeric vector of breaks for the cuts.

vector_labels

Vecotr of labels for the cuts. Must be one entry shorter than vector_cuts.

overwrite

Logical. Should the New.state.colname overwrite a preexisting column in the dataset

Value

The input dataset with an additional (or overwritten) column containing a cut light vector

References

https://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.3001571

See also

Examples

sample.data.environment |> 
Brown_cut() |> 
dplyr::count(state)
#> # A tibble: 8 × 3
#> # Groups:   Id [2]
#>   Id          state      n
#>   <fct>       <fct>  <int>
#> 1 Environment ≤1lx    6768
#> 2 Environment ≤10lx    247
#> 3 Environment NA       523
#> 4 Environment ≥250lx  9742
#> 5 Participant ≤1lx   20315
#> 6 Participant ≤10lx   5781
#> 7 Participant NA     15892
#> 8 Participant ≥250lx  9852