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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -