% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/insert_matrix_column.R
\name{insert_matrix_column}
\alias{insert_matrix_column}
\title{Insert column in matrix}
\usage{
insert_matrix_column(A, x, p)
}
\arguments{
\item{A}{[\code{matrix()}]\cr
A \code{matrix}.}

\item{x}{[\code{atomic()}]\cr
The column to be added, of length \code{nrow(A)}.

Can also be a single value.}

\item{p}{[\verb{integer())}]\cr
The position(s) where to add the column, one or more of:
\itemize{
\item \code{p = 0} appends the column left
\item \code{p = ncol(A)} appends the column right
\item \code{p = n} inserts the column between the \code{n}-th and
\code{(n + 1)}-th column of \code{A}.
}}
}
\value{
A \code{matrix}.
}
\description{
This function inserts a column into a matrix.
}
\examples{
A <- diag(3)
x <- 1:3
insert_matrix_column(A, x, 0)
insert_matrix_column(A, x, 1)
insert_matrix_column(A, x, 2)
insert_matrix_column(A, x, 3)

### also single value
x <- 2
insert_matrix_column(A, x, 0)

### also multiple positions
insert_matrix_column(A, x, 0:3)

### also trivial case
insert_matrix_column(matrix(nrow = 0, ncol = 0), integer(), integer())
}
\seealso{
Other matrix helpers: 
\code{\link{check_correlation_matrix}()},
\code{\link{check_covariance_matrix}()},
\code{\link{check_one_hot_matrix}()},
\code{\link{check_transition_probability_matrix}()},
\code{\link{cov_to_chol}()},
\code{\link{diff_cov}()},
\code{\link{matrix_diagonal_indices}()},
\code{\link{matrix_indices}()},
\code{\link{sample_correlation_matrix}()},
\code{\link{sample_covariance_matrix}()},
\code{\link{sample_transition_probability_matrix}()},
\code{\link{stationary_distribution}()}
}
\concept{matrix helpers}
\keyword{transformation}
