sample_random_n: Sample n patients (or other observational units) based on...

View source: R/sampling.R

sample_random_nR Documentation

Sample n patients (or other observational units) based on patient IDs.

Description

Sample n patients (or other observational units) based on patient IDs.

Usage

sample_random_n(id, n)

Arguments

id

An integer patient identifier with the following properties:

  • consistent between cohort extracts

  • unique

  • completely randomly assigned (no correlation with practice ID, age, registration date, etc etc) which should be true as it based on hash of true IDs

  • strictly greater than zero

n

The number of patients (amongst all those who did not experience the event) to be sampled

Details

Result is TRUE with probability max(1,n/length(id)) and FALSE with probability min(0, 1 - n/length(id)). Patients are selected in ascending order of patient ID until the sampling number is met. Warns (does not fail) if n is greater than length(id).

Value

A logical vector indicating whether the patient has been sampled or not


wjchulme/osutils documentation built on Dec. 20, 2024, 9:56 a.m.