% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fd_block.R
\name{fd_block}
\alias{fd_block}
\title{Define a multi-column feature block}
\usage{
fd_block(x, expected_names = NULL, envir = NULL)
}
\arguments{
\item{x}{Block definition input. Must be either a function or a single
expression-like input that later evaluates to a \code{data.frame}.}

\item{expected_names}{Optional character vector of expected output column
names. If supplied, names must be non-empty, non-\code{NA}, and unique.
These names are not required for normal operation, but they can later be
used by \code{fd_compute()} for validation and for optional NA-completion of
expected-but-missing outputs.}

\item{envir}{Optional environment used when normalizing expression-like
inputs. If \code{NULL}, the calling environment is used.}
}
\value{
An object of class \code{"featdelta_block"}.
}
\description{
Creates a block definition object for use inside \code{fd_define()}.
}
\details{
A block represents one ordered definition step that may produce multiple
feature columns when later evaluated by \code{fd_compute()}. Unlike ordinary
named single-column definitions, a block may return a whole \code{data.frame}
whose column names become the produced feature names.

Supported block inputs are:
\itemize{
\item an inline expression, including braced expressions such as
\code{{ data.frame(...) }}
\item a quosure
\item an \code{expression()} object of length 1
\item a quoted call or symbol
\item a function, intended to receive the current working data and return a
\code{data.frame}
}

\code{fd_block()} does not compute anything by itself. It only stores the block
definition in a normalized form so that \code{fd_define()} can include it in the
ordered definitions object.
}
\examples{
# Inline expression block
blk <- fd_block({
  data.frame(
    hp_per_cyl = hp / cyl,
    disp_per_cyl = disp / cyl
  )
})

# Function-based block
make_engine_features <- function(data) {
  data.frame(
    hp_per_cyl = data$hp / data$cyl,
    disp_per_cyl = data$disp / data$cyl
  )
}

blk <- fd_block(make_engine_features)

# Optional expected names
blk <- fd_block(
  {
    data.frame(
      hp_per_cyl = hp / cyl
    )
  },
  expected_names = c("hp_per_cyl", "disp_per_cyl")
)

}
\seealso{
Other featdelta defs helpers: 
\code{\link{fd_define}()},
\code{\link{print.featdelta_defs}()},
\code{\link{summary.featdelta_defs}()}
}
\concept{featdelta defs helpers}
