Writes a small, correctly shaped CSV showing the layout [bd_analyze_csv()] and [read_survival_data()] expect. Fill it in with your own data, or use it as a reference for renaming the columns of an existing file.
Usage
bd_csv_template(
path,
type = c("univariate", "complete", "covariate", "competing"),
n = 10,
overwrite = FALSE
)Arguments
- path
Destination file path. Use [tempfile()] if you only want to inspect the result.
- type
Which layout to write: `"univariate"` gives `time` and `status`; `"complete"` gives `time` alone, for an uncensored sample; `"covariate"` adds two example covariate columns; `"competing"` gives `time` and `cause`.
- n
Number of illustrative rows. Default 10.
- overwrite
Logical; overwrite an existing file. Default `FALSE`.
Details
The illustrative values are plausible but arbitrary. `status` is coded 1 = event observed, 0 = right-censored. For `"competing"`, `cause` is coded 0 = censored and 1, 2, ... for the competing causes.
Examples
p <- bd_csv_template(tempfile(fileext = ".csv"), type = "covariate", n = 5)
#> Wrote a 'covariate' template with 5 row(s) to: /tmp/Rtmpwgv1YV/file19e57e33bc40.csv
read.csv(p)
#> time status age group
#> 1 4.9 1 45 treated
#> 2 9.4 1 62 control
#> 3 16.3 0 51 treated
#> 4 21.3 1 70 control
#> 5 27.5 1 45 treated
unlink(p)