melt {reshape}R Documentation

Melt

Description

Melt a data frame into form suitable for easy casting.

Usage

melt(data, id.var, measure.var, variable_name = "variable", preserve.na = TRUE)

Arguments

data Data set to melt
id.var Identifying variables. If blank, will use all non measure.var variables
measure.var Measured variables. If blank, will use all non id.var variables
variable_name Name of the variable that will store the names of the original variables
preserve.na Should NAs be preserved or dropped from the data set?

Details

Along with cast and recast, melt is the only function from this package you will actually use. The rest are all support functions for these two. melt gets your data into a suitable form (molten) for cast to work on.

You need to tell melt which of your variables are id variables, and which are measured variables. For most practical uses, the id variables will be categorical, and the measured variables continuous. If you only supply one of id.var and measure.var, melt will assume the remainder of the variables in the data set belong to the other. If you supply neither, melt will assume integer and factor variables are id variables, and all other are measured.

Value

molten data

Author(s)

Hadley Wickham <h.wickham@gmail.com>

See Also

http://had.co.nz/reshape/

Examples

data(tips)
head(melt(tips))
names(airquality) <- tolower(names(airquality))
airquality.d <- melt(airquality, id=c("month", "day"))
head(airquality.d)
names(ChickWeight) <- tolower(names(ChickWeight))
chick.d <- melt(ChickWeight, id=2:4)

[Package reshape version 0.6.1 Index]