This will add the pair-pulse ratio value to rows where the stimulus == 2 and event_index == 1. For paired stimuli
with no event on the 2nd stimulus, 0
is returned; for stimuli with no event on the 1st stimulus, NA
is
returned.
Arguments
- df
Data Frame or Tibble with the following columns:
sweep
condition
stimulus
event_index
amplitude OR another reference column
- column_ref
Character, column to use for ppr calculation. Defaults to
"amplitude"
.
Examples
n <- 2
simple_df <-
data.frame(
sweep = rep(1:(4 * n), each = 2),
condition = rep(c(NA, "control", "drug_1", "drug_2"), each = (2 * n)),
amplitude = c(rep(c(40, 20), n), rep(c(40, 20), n), rep(c(10, NA), n), rep(c(NA, 30), n)),
stimulus = rep(1:2, 4 * n),
event_index = 1
)
add_ppr(df = simple_df, column_ref = "amplitude")
#> sweep condition amplitude stimulus event_index ppr
#> 1 1 <NA> 40 1 1 NA
#> 2 1 <NA> 20 2 1 0.5
#> 3 2 <NA> 40 1 1 NA
#> 4 2 <NA> 20 2 1 0.5
#> 5 3 control 40 1 1 NA
#> 6 3 control 20 2 1 0.5
#> 7 4 control 40 1 1 NA
#> 8 4 control 20 2 1 0.5
#> 9 5 drug_1 10 1 1 NA
#> 10 5 drug_1 NA 2 1 NA
#> 11 6 drug_1 10 1 1 NA
#> 12 6 drug_1 NA 2 1 NA
#> 13 7 drug_2 NA 1 1 NA
#> 14 7 drug_2 30 2 1 0.0
#> 15 8 drug_2 NA 1 1 NA
#> 16 8 drug_2 30 2 1 0.0