% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tidyr.R
\name{tf_gather}
\alias{tf_gather}
\title{Gather all columns representing functional measurements into a \code{tfd}-object}
\usage{
tf_gather(
  data,
  ...,
  key = ".tfd",
  arg = NULL,
  domain = NULL,
  evaluator = tf_approx_linear
)
}
\arguments{
\item{data}{a data frame -- note that \code{dplyr} does not handle matrix columns well,
if \code{data} contains more than one of those, \code{tf_gather} will fail...}

\item{...}{A selection of columns to collect as a \code{tfd} object. Each column
represents measurements of a functional variable at a specific \code{arg}-val.
Can also be the name of a matrix-valued column, but see above.
If empty, all variables are selected. You can supply bare variable names,
select all variables between x and z with x:z, exclude y with -y. For more
options, see the \code{\link[dplyr:select]{dplyr::select()}} documentation.}

\item{key}{the name of the created \code{tfd}-column. Defaults to \code{".tfd"}, but
the function will try to guess the name based on the column names of the
gathered columns in this case. If a common prefix of all column names
is found, this is used instead. You also get a message about this.}

\item{arg}{optional. Argument values for the functions. If not provided, will be guessed from the column names as well.
See also \code{\link[tf:tfd]{tf::tfd()}}.}

\item{domain}{optional. Range of possible \code{arg}-values. See \code{\link[tf:tfd]{tf::tfd()}} for details.}

\item{evaluator}{optional. A function accepting arguments x, arg, evaluations. See \code{\link[tf:tfd]{tf::tfd()}} for details.}
}
\value{
a modified \code{data.frame} with a \code{tfd} column replacing the \code{...}.
}
\description{
Similar in spirit to \code{\link[tidyr:gather]{tidyr::gather()}}, but does NOT put the values in the
gathered columns into one very long "value"-column while labeling the different
original columns in a very long "key"-column -- instead it creates a \code{tfd}-column
containing the functional measurements of the columns given in \code{...}.
}
\examples{
d <- tf_spread(growth[1:5, ]) |> dplyr::mutate(id = 1:dplyr::n())
dplyr::glimpse(d)
# tidyselect syntax for column selection:
tf_gather(d, starts_with("height"))
tf_gather(d, height_1:height_18)
tf_gather(d, -gender, -id)
# custom key name and arg values:
tf_gather(d, starts_with("height"), key = "height")
tf_gather(d, starts_with("height"), arg = seq(0, 1, length.out = 31))
}
\seealso{
\code{\link[dplyr:select]{dplyr::select()}}

Other tidyfun data wrangling functions: 
\code{\link{tf_evaluate.data.frame}()},
\code{\link{tf_nest}()},
\code{\link{tf_spread}()},
\code{\link{tf_unnest}()}
}
\concept{tidyfun data wrangling functions}
