R Droplevels Function Fail With Factor -
my dataframe named 'data' contains variable named 'income' 26 levels. want delete or drop level 'refused' there 25 levels.
below truncated printout of levels. see number 26 'refused':
> levels(data$income) [1] "under $1 000" "$1 000 2 999" "$3 000 3 999" , on... [25] "$150000 or over" "refused"
i researched droplevels
function , tried this:
data <- droplevels(income$refused)
this:
droplevels(data, income$refused)
and this:
data %<>% droplevels(income$refused)
i think problem may class factor. documentation on droplevels
isn't easy decipher.
droplevels()
drops values not in use; can't use drop explicit levels. if want drop rows "refused" , drop levels factor, use this
droplevels(subset(data, income!="refused"))
Comments
Post a Comment