Skip to contents

Determines the sweep/trial number based upon the event time, rec_time_ms.

Usage

add_sweep_number_to_rows(
  df,
  sweep_duration,
  sweep_count,
  time_ref = "rec_time_ms"
)

Arguments

df

Data Frame or Tibble

sweep_duration

Numeric, sweep/trial duration in seconds.

sweep_count

Numeric, total number of experiment sweeps/trials.

time_ref

Character, event time reference point column name, i.e. rec_time_ms.

Value

Data Frame or Tibble with the following columns:

  • sweep, Ordered Factor

Examples

simple_df <- data.frame(rec_time_ms = c("400.50", "4,400.50"))

add_sweep_number_to_rows(
  df = simple_df,
  sweep_duration = 1,
  sweep_count = 5,
  time_ref = "rec_time_ms"
)
#>   rec_time_ms sweep
#> 1       400.5     1
#> 2      4400.5     5

if (FALSE) {
df <- add_sweep_number_to_rows(
  df = data,
  sweep_duration = matools_env$sweep_duration_sec,
  sweep_count = matools_env$sweeps_total,
  time_ref = "rec_time_ms"
)
}