Learn R Programming

OpasnetUtils (version 1.3)

dropall: Dropall

Description

Drops unused factor levels in data.frames

Usage

dropall(x)

Arguments

x

a data.frame

Value

data.frame

Details

This function makes sure that the factor levels in a data.frame do not contain entries that have already been removed from the factor itself.

See also: http://en.opasnet.org/

Examples

Run this code
a <- data.frame(A = c("a", "b"), B = c(1,1))
levels(a[[1]])

a <- a[-2 ,]
levels(a[[1]])
a[[1]]

a <- dropall(a)
levels(a[[1]])
a[[1]]

Run the code above in your browser using DataLab