mirror of
https://github.com/prise6/aVirtualTwins.git
synced 2024-05-18 22:16:32 +02:00
Fix issue trt/outcome
This commit is contained in:
parent
39b1757fb5
commit
131599a3d5
|
@ -48,11 +48,13 @@ formatRCTDataset <- function(dataset, outcome.field, treatment.field, interactio
|
|||
if(!is.factor(outcome)) outcome <- as.factor(outcome)
|
||||
if(!length(levels(outcome)) == 2L) stop(sprintf("outcome %s must be binary", outcome.field))
|
||||
cat(sprintf("\"%s\" will be the favorable outcome \n", levels(outcome)[2]))
|
||||
d[, outcome.field.which] <- outcome
|
||||
|
||||
treatment <- d[, treatment.field.which]
|
||||
if(!is.numeric(treatment) & !is.integer(treatment)) treatment <- as.numeric(treatment)
|
||||
if(!( length(unique(treatment)) == 2L & all(c(0,1) %in% unique(treatment)) ))
|
||||
stop(sprintf("%s, response must be numeric:\n 0 = no treatment \n 1 = treatment \n", treatment.field))
|
||||
d[, treatment.field.wich] <- treatment
|
||||
|
||||
predictors <- colnames(dataset)[-c(outcome.field.which, treatment.field.which)]
|
||||
|
||||
|
|
Loading…
Reference in a new issue