\encoding{UTF-8}
\name{write_kstructure}
\alias{write_kstructure}
\title{Write a knowledge structure file}

\description{
  Write a knowledge structure to
  a file. The file formats are described in the \link{kstIO-package}
  information page.
}

\usage{
  write_kstructure(x, 
                   filename, 
                   format = NULL, 
                   sep=',',
                   enforce = TRUE)
}

\arguments{
  \item{x}{The data to be written, either a binary matrix or an object
    of \code{kstructure} class.}
  \item{filename}{A character string specifying the name of the base file.}
  \item{format}{Specification of the files format. Can be "SRBT" (default), "KST", 
    "matrix", or spreadsheet formats. Default is NULL}
  \item{sep}{Cell separator for CSV files - otherwise ignored.}
  \item{enforce}{Enforce structure properties? [Default is TRUE]}
}


\details{
  The \code{format} values refer to the different generations of file formats 
  described in \link{kstIO-package}.  
}

\references{
  Hockemeyer, C. (2001). \emph{KST Tools User Manual} (2nd ed.). 
  \url{https://resources.cord-hockemeyer.info/techreports/KST-Tools_TechRep_FWF01.pdf}.

  Poetzi, S. & Wesiak, G. (2001). \emph{SRbT Tools User Manual.}
  \url{https://resources.cord-hockemeyer.info/techreports/SRBT-Tools_TechRep_FWF01.pdf}
}

\author{Cord Hockemeyer \email{cord.hockemeyer@uni-graz.at}}

\seealso{\code{\link[kst]{kstructure}},
	 \link{kstIO-package}
}

\examples{
# Obtain data to write from the 'pks' package
d <- getwd()
setwd(tempdir())
kst <-kmunionclosure(phsg$basis)
# Write structure to file
write_kstructure(kst, "phsg.struct") # Write in (default) SRBT format
# Write the matrix in CSV format
write_kstructure(kst, "phsg.csv") 
setwd(d)
}

\keyword{file}
