unname
Remove "names" or "dimnames"

Description

Removes the names or dimnames of an object.

Usage

unname(obj, force = FALSE)

Arguments

obj an object for which you want to remove the names or dimnames.
force a logical value. If TRUE, dimnames are always removed, even if obj is a data frame. If FALSE (the default), dimnames are removed only when obj is not a data frame. (obj can be a matrix, an array, or other object type.)

This argument does not affect the names of an object.

Value
returns an object like obj, but without names or dimnames.
Examples

x <- c(1:12) names(x) <- as.character(1:12) unname(x)

x <- array(runif(24), c(2, 4, 3), list(c("r1","r2"), c("c1", "c2", "c3", "c4"), c("s1", "s2", "s3"))) unname(x)

# data frame x <- as.data.frame(matrix(runif(20), 5, 4))

# error, dimnames of data frame can't be null unname(x, force = TRUE) unname(x) # the column names are removed.

# Some calculations are substantially faster if you remove names # from input vectors first. z1 <- runif(1000) names(z1) <- as.character(1:1000)

# sys.time is used system.time(for(i in 1:1000) z1[i] <- z1[i]) z1 <- unname(z1)

# sys.time is used system.time(for(i in 1:1000) z1[i] <- z1[i])

Package base version 6.1.4-13
Package Index