outcome.counts.to.rows: Transform data with counts of binary outcomes into repeated...

View source: R/outcome-counts-to-rows.R

outcome.counts.to.rowsR Documentation

Transform data with counts of binary outcomes into repeated rows.

Description

Given a data.frame containing results of a test with two possible outcomes that is arranged with the number of "successes" per group in one column and the number of "failures" per group in another column, return a new data.frame that has a single outcome column with 1 for every success and 0 for every failure, mapping each outcome to a single row.

Usage

outcome.counts.to.rows(data, success.counts, failure.counts, outcome)

Arguments

data

data.frame with columns for success and failure counts.

success.counts

Column with number of successes per group.

failure.counts

Column with number of failures per group.

outcome

Name to use for the outcome column.

Details

The output is the format glm() expects when constructing logistic regressions. The "successes" and "failures" can be any two mutually exclusive states. Note that, while one would expect these to be logical (TRUE and FALSE) values, glm() requires numeric values. You can think about these numbers as representing the probability of success, which is 1 for success that actually happened and 0 for successes that did not.

Value

A data.frame with counts represented as repeated rows with a number 1 representing a success or a 0 representing a failure.


Ergative/logisticat documentation built on May 17, 2022, 12:32 a.m.