View source: R/calculate_roc.R
melt_roc | R Documentation |
Multiple biomarkers measured on the same subjects are often stored as multiple columns in a data frame. This is a convenience function that transforms the data into long format, suitable for use with ggplot and geom_roc
melt_roc(data, d, m, names = NULL)
data |
Data frame containing disease status and biomarkers stored in columns |
d |
Column containing binary disease status. Can be a column name or index |
m |
Vector of column names or indices identifying biomarkers |
names |
Optional vector of names to assign to the biomarkers. If NULL, names will be taken from the column names |
A data frame in long format with three columns: D = binary disease status, M = biomarker value, and name = biomarker name
D.ex <- rbinom(50, 1, .5)
widedata <- data.frame(D = D.ex, M1 = rnorm(50, mean = D.ex, sd = 1),
M2 = rnorm(50, mean = D.ex, sd = .5))
longdata <- melt_roc(widedata, "D", c("M1", "M2"))
ggplot(longdata, aes(d = D, m = M, color = name)) + geom_roc()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.