count_to_binary: Count to Binary Dataframe

View source: R/count_to_binary.R

count_to_binaryR Documentation

Count to Binary Dataframe

Description

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.

Usage

count_to_binary(dat, x, y, time)

Arguments

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.

Examples

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)


UKBiostatCIRCL/UK-Biostat-CIRCL documentation built on June 30, 2022, 4:42 a.m.