View source: R/count_to_binary.R
count_to_binary | R Documentation |
This function receives the inputs of a count-based dataframe - typically longitudinal in nature - and converts these counts to binary form where each row represents an independent event resulting in a 0 or 1 outcome. This may be useful in situations of n events, choose k successes.
count_to_binary(dat, x, y, time)
dat |
A dataframe in person-period/long format. |
x |
A numeric vector representing the total number of events (n). |
y |
A numeric vector representing the total number of successes (k). |
time |
A numeric vector representing the time points. |
dat = data.frame(x = rpois(100, 10), y = rpois(100, 1), time = seq(1:100)) new_dat = count_to_binary(dat, dat$x, dat$y, dat$time)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.