-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle more than one factor variables (How to simulate missings) #58
Comments
I refer to website/static/how-to/generate/amputation.R Lines 165 to 174 in aedd584
|
rabea-a
changed the title
handle more than one factor variables
handle more than one factor variables (How to simulate missings)
Jul 8, 2020
Hello, if (length(vars_factor) > 0){
for (i in 1:length(vars_factor)){
tmp$data.init[,vars_factor[[i]]] <- as.factor(tmp$data.init[,vars_factor[[i]]])
tmp$data.incomp[,vars_factor[[i]]] <- as.factor(tmp$data.incomp[,vars_factor[[i]]])
if(length(vars_factor) == 1){
gdata::mapLevels(x=tmp$data.init[,vars_factor[[i]]]) <- levels_factor[[i]]
gdata::mapLevels(x=tmp$data.incomp[,vars_factor[[i]]]) <- levels_factor[[i]]
}else{
gdata::mapLevels(x=tmp$data.init[,vars_factor[[i]]]) <- levels_factor[[1]][[i]]
gdata::mapLevels(x=tmp$data.incomp[,vars_factor[[i]]]) <- levels_factor[[1]][[i]]
}
}
} Greetings, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @imkemayer,
it's me again, sorry! I think your temporary fix to handle factors fails for more than one factor variable. Below you see a minimal example which causes an error:
I think the case distinction of the two if queries is not necessary and should be removed. Instead, insert
for all length of
vars_factor
.Furthermore, the correct indexing needs be used in lines 466 and 467 afterwards (also you have to check in case of
by.patterns==TRUE
):I look forward to hearing your opinion of my thoughts.
Best,
Rabea.
The text was updated successfully, but these errors were encountered: