Skip to content
Prev 257969 / 398506 Next

Factor function

On Mon, Apr 25, 2011 at 12:53:40PM -0700, Lisa wrote:
The column d[, 3] is already a factor. It is possible to avoid
this using

  d<-data.frame(matrix(c("ww","ww","xx","yy","ww","yy","xx","yy","NA"),
  ncol=3, byrow=TRUE), stringsAsFactors=FALSE)

Then, we get

  factor(d[, 3], exclude="NA")

  [1] xx   yy   <NA>
  Levels: xx yy

Hope this helps.

Petr Savicky.