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", na.rm = !preserve.na, preserve.na = TRUE, ...)
data |
Data set to melt |
id.var |
Id 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 |
na.rm |
Should NAs be removed from the data set? |
preserve.na |
Old argument name, now deprecated |
... |
You need to tell melt which of your variables are id variables, and which
are measured variables. 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>
head(melt(tips)) names(airquality) <- tolower(names(airquality)) melt(airquality, id=c("month", "day")) names(ChickWeight) <- tolower(names(ChickWeight)) melt(ChickWeight, id=2:4)