View source: R/km_type_weights.R
prepare_risk_table | R Documentation |
Given a nested case-control (NCC) data, create a template for users to fill in the number of subjects at risk in the cohort at each event time within each sampling stratum (if applicable).
prepare_risk_table( ncc, t_match_name, y_name, match_var_names = NULL, csv_file = NULL )
ncc |
Nested case-control data. A |
t_match_name |
Name of the column of event time in each matched set in
|
y_name |
Name of the case/control indicator in |
match_var_names |
Name(s) of the match variable(s) used when drawing the
NCC. A |
csv_file |
Name of CSV file to write the template to. If left
unspecified, the template will be returned as a |
If csv_file
is not supplied, this function returns a
data.frame
that contains the unique event times, additional matching
variables (if match_var_names
is supplied), and an empty column
named n.risk
. Column names in this data.frame
should not be
modified. If csv_file
is supplied, this function write the
data.frame
to the designated file instead. Users should fill this
column with the number of subjects at risk at each time point in the
stratum, and later use this data.frame
or file to compute the
KM-type weights for the subjects in the NCC data.
library(SamplingDesignTools) data("ncc_2") risk_table <- prepare_risk_table(ncc = ncc_2, t_match_name = "Time", y_name = "Fail", match_var_names = c("age_cat", "gender")) head(risk_table)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.