% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mixing_ability.R
\name{pivotMixData2Long}
\alias{pivotMixData2Long}
\title{Pivot mixture data into the long format}
\usage{
pivotMixData2Long(
  df,
  genos,
  colC,
  sep = "-",
  prefixY = NULL,
  sepY = "_",
  colIDfocal = "focal",
  colIDneighbors = "neighbor"
)
}
\arguments{
\item{df}{data frame}

\item{genos}{named list of vectors, one per species, containing all the identifiers of the genotypes of the given species}

\item{colC}{name of the column containing the component(s) of each stand}

\item{sep}{separator used to separate the genotype names in \code{"col"}; see the \code{"split"} argument of \code{\link{strsplit}}}

\item{prefixY}{prefix of the columns containing the yield data (one column per mixture component); it is assumed that the components in \code{colC} are in the same order as the yield data}

\item{sepY}{separator used in the name of the new "yield" columns made by concatenating \code{colY} and \code{colIDfocal} or \code{colIDneighbors}}

\item{colIDfocal}{name of the column in the output that will contain the identifiers of the focal genotypes}

\item{colIDneighbors}{name of the column in the output that will contain the identifiers of the neighbor genotypes; for monovarietal stands, the entries in this neighbor column will be identical to the entries in the focal column}
}
\value{
data.frame with more rows
}
\description{
Pivots mixture data into the long format, from one row per stand into one row per component of each stand (i.e., several rows if the stand is a mixture).
}
\examples{
## example of species mixtures:
(dat <- data.frame(name=c("wheat01-pea02","wheat01-pea01", "wheat01"),
                   stand=c("inter","inter","sole"),
                   x=c(1, 1, 1),
                   y=c(1, 2, 3),
                   "yield_cereal" = c(10, 11, 20),
                   "yield_legume" = c(9, 8, NA),
                   check.names = FALSE,
                   stringsAsFactors=TRUE))
pivotMixData2Long(df=dat, colC="name", sep="-", prefixY="yield",
                  genos=list("cereal"=c("wheat01"),
                             "legume"=c("pea01","pea02")))

## example of varietal mixtures:
(dat <- data.frame(name=c("g1+g2","g1+g2","g1","g2"),
                   "yield_focal" = c(10, 12, 20, 18),
                   "yield_neighbor" = c(11, 9, NA, NA),
                   check.names = FALSE,
                   stringsAsFactors=TRUE))
pivotMixData2Long(df=dat, colC="name", sep="+", prefixY="yield",
                  genos=list(c("g1","g2")))
}
\seealso{
\code{\link{pivotMixData2Wide}}
}
