melt.data.frame {reshape} | R Documentation |
Melt a data frame into form suitable for easy casting.
melt.data.frame(data, id.var, measure.var, variable_name = "variable", preserve.na = TRUE, ...)
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? |
... |
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.
molten data
Hadley Wickham <h.wickham@gmail.com>
vignette("introduction", "reshape"), http://had.co.nz/reshape/
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)