patientProfile: Profile of common covariate combinations among patients

View source: R/patientProfiles.R

patientProfileR Documentation

Profile of common covariate combinations among patients

Description

Profile of common covariate combinations among patients

Usage

patientProfile(dt, primary.cov, ...)

Arguments

dt

Data.table object where each row represents a patient and each row represents a covariates (or risk factor)

primary.cov

An integer, character, or factor vector. The primary covariate to group by and calculate proportions for (usually age)

...

Additional covariates to group by - e.g. gender, status of previous exposures/events, etc. Accepts vectors of integers, characters or factors

Details

The function is designed to show how many patients exists in the dataset that have each combination of risk factors.

Covariate combinations will that conatin 0 patients will return a 0 value for that covariate combination. However, this assumes that all possible outcomes for each variable are found in at least one patient in the dataset. For example, using "age" as a covariate, if the dataset ranges from 20 to 50 years olds, it is assumed that at least one patient from every interger age is present i.e. 20, 21, 22....50. If there are no patients aged 22, for example, then no covariate combinations with patients aged 22 will be created.

Value

Returns a data.table object where each row is a covariate combination. N.in.primary.cov records the number of patients in the data set with the specified primary covariate. E.g. using the "age" example from the "details" section, this column would record how many patients are 20, 21, 22....50. prop.by.primary.cov records the proportion of patients with the same primary covariate (primary.cov) with that parameter combination.

Author(s)

Matthew Phelps mphelps@hjerteforeningen.dk

Examples

  n <- 1e2
  set.seed(13)
  x <- data.table::data.table(
    age = sample(20:35, size = n, replace = TRUE),
    v2 = sample(c("yes", "no"), n, replace = TRUE),
    v3 = sample(c("yes", "no"), n, replace = TRUE, prob = c(0.2, 0.8))
  )
  out <- patientProfile(dt = x, primary.cov = "age", "v2", "v3")


tagteam/heaven documentation built on Oct. 24, 2024, 7:40 p.m.