% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/table_helpers.R
\name{export_BRRAT_csv}
\alias{export_BRRAT_csv}
\title{Export global and per-site summaries to CSV}
\usage{
export_BRRAT_csv(fit_obj, file_global, file_per_id, level = 0.95)
}
\arguments{
\item{fit_obj}{A fitted object returned by \code{\link[=BRRAT]{BRRAT()}}, of class \code{BRRAT}.}

\item{file_global}{Path/filename for the global table CSV. No default is
provided; the user must supply an explicit path (e.g. via \code{\link[=tempfile]{tempfile()}} or
a user-chosen location).}

\item{file_per_id}{If applicable to the model, path/filename for the
per-site table CSV. No default is provided; the user must supply an
explicit path.}

\item{level}{Credible interval level passed to \code{\link[=summarise_BRRAT]{summarise_BRRAT()}} (default \code{0.95}).}
}
\value{
(Invisibly) a list with the two data frames written:
\verb{list(global = <data.frame>, per_id = <data.frame>)}.
}
\description{
Writes the output of \code{\link[=summarise_BRRAT]{summarise_BRRAT()}} to two CSV files: one for the
population slope (\code{file_global}) and one for per-site coefficients (\code{file_per_id}).
}
\details{
Export summary tables to CSV files
}
\examples{
\donttest{
set.seed(1)
samples <- 30
Clim <- sort(pmax(0, rnorm(samples, 600, 100)))
observed <- pmax(0, (Clim - 150) - 450 * tanh((Clim - 150) / 450))
Obs <- data.frame(P = Clim, Q = observed, year = 1:samples)
Sim <- data.frame(Q = observed * rnorm(samples, 1, 0.05), year = 1:samples)
res <- BRRAT(Sim, Obs, chains = 1, iter = 500)
export_BRRAT_csv(res,
  file_global = tempfile(fileext = ".csv"),
  file_per_id = tempfile(fileext = ".csv"),
  level = 0.95
)
}

}
