File: drop.levels.R

package info (click to toggle)
gdata 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: sh: 27; makefile: 15
file content (23 lines) | stat: -rw-r--r-- 472 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
drop.levels  <- function(x, reorder=TRUE, ...)
  UseMethod("drop.levels")

drop.levels.default <- function(x, reorder=TRUE, ...)
  x

drop.levels.factor <- function(x, reorder=TRUE, ...)
{
  x <- x[, drop=TRUE]
  if(reorder) x <- reorder(x, ...)
  x
}

drop.levels.list <- function(x, reorder=TRUE, ...)
{
  lapply(x, drop.levels, reorder=reorder, ...)
}

drop.levels.data.frame <- function(x, reorder=TRUE, ...)
{
  x[] <- drop.levels.list(x, reorder=reorder, ...)
  x
}