I used R package Broom for getting my results as data.frame from lm. This worked well, but causes problem with my ifelse command. Script that worked well before installing the broom package is following:
df$newvariable <- ifelse((df$oldvariable == 0) | is.na(df$oldvariable), 0, ifelse((df$oldvariable == 1), 1, df$newvariable))
Now it gives following error:
Error in ifelse((df$oldvariable == 1), 1, df$newvariable) : replacement has length zero In addition: Warning messages: 1: Unknown column 'newvariable' 2: In rep(no, length.out = length(ans)) : 'x' is NULL so the result will be NULL
I can avoid this still, if i don't install broom package. No changes to original data.frame has been made that could cause this.
Why broom package causes ifelse command to fail?
Aucun commentaire:
Enregistrer un commentaire