Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

melt.array

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

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)

reshape2

Flexibly Reshape Data: A Reboot of the Reshape Package

v1.4.4
MIT + file LICENSE
Authors
Hadley Wickham <h.wickham@gmail.com>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.