The function droplevels is used to drop unused levels from a factor or, more commonly, from factors in a data frame.

droplevels(x, ...)

# S4 method for DataFrame
droplevels(x)

# S4 method for Ranges
droplevels(x)

Arguments

x

Object.

...

Additional arguments.

Value

Modified object.

Note

Updated 2021-02-03.

Examples

data(GRanges, package = "AcidTest") ## Ranges ==== object <- GRanges object <- droplevels(object) print(object)
#> GRanges object with 5 ranges and 2 metadata columns: #> seqnames ranges strand | geneId #> <Rle> <IRanges> <Rle> | <Rle> #> ENSG00000000003 X 100627109-100639991 - | ENSG00000000003 #> ENSG00000000005 X 100584802-100599885 + | ENSG00000000005 #> ENSG00000000419 20 50934867-50958555 - | ENSG00000000419 #> ENSG00000000457 1 169849631-169894267 - | ENSG00000000457 #> ENSG00000000460 1 169662007-169854080 + | ENSG00000000460 #> geneName #> <Rle> #> ENSG00000000003 TSPAN6 #> ENSG00000000005 TNMD #> ENSG00000000419 DPM1 #> ENSG00000000457 SCYL3 #> ENSG00000000460 C1orf112 #> ------- #> seqinfo: 357 sequences from GRCh38 genome