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 ...@@ -106,7 +106,6 @@ tbl_combined$Outcomes.DerivedCompositeGOSE %>% table
# Impute # Impute
```{r impute} ```{r impute}
tbl_gose_msm <- tbl_combined %>% tbl_gose_msm <- tbl_combined %>%
select( select(
...@@ -163,7 +162,7 @@ fit <- msm::msm( ...@@ -163,7 +162,7 @@ fit <- msm::msm(
censor.states = 2:7, # cannot be dead since these were filtered previously censor.states = 2:7, # cannot be dead since these were filtered previously
control = list( control = list(
fnscale = 12000, fnscale = 12000,
maxit = 10^4, maxit = 10, # 10^4,
trace = 2 trace = 2
) )
) )
...@@ -196,7 +195,7 @@ tbl_posteriors <- tibble( ...@@ -196,7 +195,7 @@ tbl_posteriors <- tibble(
mutate( mutate(
probability = ifelse(gose == "1", 0.0, probability), probability = ifelse(gose == "1", 0.0, probability),
probability = probability / sum(probability), probability = probability / sum(probability),
gose = sprintf("gose_%s_probability", gose) gose = sprintf("gose_%s_probability", gose)
) %>% ) %>%
ungroup %>% ungroup %>%
pivot_wider(names_from = gose, values_from = probability) pivot_wider(names_from = gose, values_from = probability)
...@@ -331,7 +330,7 @@ tbl_final_imputations %>% ...@@ -331,7 +330,7 @@ tbl_final_imputations %>%
```{r save-imputed-values} ```{r save-imputed-values}
tbl_final_imputations %>% { tbl_final_imputations %>% {
tmp <- . tmp <- .
names(tmp) <- gsub("gose", "Outcomes.DerivedGOSE", x = names(.)) names(tmp) <- gsub("gose", "Subject.Subject.DerivedImputed180DaysGOSE", x = names(.))
tmp } %>% tmp } %>%
write_csv("tbl_imputed_gose.csv") write_csv("tbl_imputed_gose.csv")
``` ```
......
...@@ -15,8 +15,13 @@ varnames <- c( ...@@ -15,8 +15,13 @@ varnames <- c(
"Subject.PatientType", "Subject.PatientType",
"Subject.DeathDate" "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)) if (!all(colnames == varnames))
stop("colnames do not match varnames, check order!") 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