Pages

Tuesday 3 February 2015

Dropping Factor Levels in R

  • drop.levels {gdata} # Drop unused factor levels
  • droplevels {base} # The function droplevels is used to drop unused levels from a factor or, more commonly, from factors in a data frame.
  • When creating data frame or importing data into data frame (loading data with read.table, read.csv or the like), character vectors are converted to factors by default. To avoid this, set option (stringsAsFactors = FALSE)

No comments:

Post a Comment