1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/melt.r
\name{melt.data.frame}
\alias{melt.data.frame}
\title{Melt a data frame into form suitable for easy casting.}
\usage{
\method{melt}{data.frame}(
data,
id.vars,
measure.vars,
variable.name = "variable",
...,
na.rm = FALSE,
value.name = "value",
factorsAsStrings = TRUE
)
}
\arguments{
\item{data}{data frame to melt}
\item{id.vars}{vector of id variables. Can be integer (variable position)
or string (variable name). If blank, will use all non-measured variables.}
\item{measure.vars}{vector of measured variables. Can be integer (variable
position) or string (variable name)If blank, will use all non id.vars}
\item{variable.name}{name of variable used to store measured variable names}
\item{...}{further arguments passed to or from other methods.}
\item{na.rm}{Should NA values be removed from the data set? This will
convert explicit missings to implicit missings.}
\item{value.name}{name of variable used to store values}
\item{factorsAsStrings}{Control whether factors are converted to character
when melted as measure variables. When \code{FALSE}, coercion is forced if
levels are not identical across the \code{measure.vars}.}
}
\description{
You need to tell melt which of your variables are id variables, and which
are measured variables. If you only supply one of \code{id.vars} and
\code{measure.vars}, melt will assume the remainder of the variables in the
data set belong to the other. If you supply neither, melt will assume
factor and character variables are id variables, and all others are
measured.
}
\examples{
names(airquality) <- tolower(names(airquality))
melt(airquality, id=c("month", "day"))
names(ChickWeight) <- tolower(names(ChickWeight))
melt(ChickWeight, id=2:4)
}
\seealso{
\code{\link{cast}}
Other melt methods:
\code{\link{melt.array}()},
\code{\link{melt.default}()},
\code{\link{melt.list}()}
}
\concept{melt methods}
\keyword{manip}
|