Last data update: 2014.03.03
|
R: Melt an array.
melt.array | R Documentation |
Melt an array.
Description
This code is conceptually similar to as.data.frame.table
Usage
## S3 method for class 'array'
melt(data, varnames = names(dimnames(data)), ...,
na.rm = FALSE, as.is = FALSE, value.name = "value")
## S3 method for class 'table'
melt(data, varnames = names(dimnames(data)), ...,
na.rm = FALSE, as.is = FALSE, value.name = "value")
## S3 method for class 'matrix'
melt(data, varnames = names(dimnames(data)), ...,
na.rm = FALSE, as.is = FALSE, value.name = "value")
Arguments
data |
array to melt
|
varnames |
variable names to use in molten data.frame
|
... |
further arguments passed to or from other methods.
|
na.rm |
Should NA values be removed from the data set? This will
convert explicit missings to implicit missings.
|
as.is |
if FALSE , the default, dimnames will be converted
using type.convert . If TRUE , they will be left
as strings.
|
value.name |
name of variable used to store values
|
See Also
cast
Other melt.methods: melt.data.frame ;
melt.default ; melt.list
Examples
a <- array(c(1:23, NA), c(2,3,4))
melt(a)
melt(a, na.rm = TRUE)
melt(a, varnames=c("X","Y","Z"))
dimnames(a) <- lapply(dim(a), function(x) LETTERS[1:x])
melt(a)
melt(a, varnames=c("X","Y","Z"))
dimnames(a)[1] <- list(NULL)
melt(a)
Results
|