Commit c1840dfc authored by Kevin's avatar Kevin

naming convention + minor fixed in input checking

parent 326fb908
......@@ -106,7 +106,6 @@ tbl_combined$Outcomes.DerivedCompositeGOSE %>% table
# Impute
```{r impute}
tbl_gose_msm <- tbl_combined %>%
select(
......@@ -163,7 +162,7 @@ fit <- msm::msm(
censor.states = 2:7, # cannot be dead since these were filtered previously
control = list(
fnscale = 12000,
maxit = 10^4,
maxit = 10, # 10^4,
trace = 2
)
)
......@@ -196,7 +195,7 @@ tbl_posteriors <- tibble(
mutate(
probability = ifelse(gose == "1", 0.0, probability),
probability = probability / sum(probability),
gose = sprintf("gose_%s_probability", gose)
gose = sprintf("gose_%s_probability", gose)
) %>%
ungroup %>%
pivot_wider(names_from = gose, values_from = probability)
......@@ -331,7 +330,7 @@ tbl_final_imputations %>%
```{r save-imputed-values}
tbl_final_imputations %>% {
tmp <- .
names(tmp) <- gsub("gose", "Outcomes.DerivedGOSE", x = names(.))
names(tmp) <- gsub("gose", "Subject.Subject.DerivedImputed180DaysGOSE", x = names(.))
tmp } %>%
write_csv("tbl_imputed_gose.csv")
```
......
......@@ -15,8 +15,13 @@ varnames <- c(
"Subject.PatientType",
"Subject.DeathDate"
)
colnames <- readr::read_csv(input_csv, n_max = 1) %>% names
colnames <- readr::read_csv(
input_csv,
n_max = 1, ,
col_types = "cinncD"
) %>%
names
if (!all(colnames == varnames))
stop("colnames do not match varnames, check order!")
tbl_gose_imputation <- readr::read_csv(input_csv, col_types = "cinncD")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment