% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{check_pdf}
\alias{check_pdf}
\title{Check the PDF file}
\usage{
check_pdf(PDF = "four_panels.pdf", OUTDIR = tempdir())
}
\arguments{
\item{PDF}{The name of the PDF file. Defaults to
\code{four_panels.pdf}.}

\item{OUTDIR}{The default directory where \code{PDF} will be saved to.}
}
\value{
The path to the PDF file if the file doesn't exist. It appends
the pdf file extension if it was absent from \code{PDF}.
}
\description{
This function checks that the PDF file does not exist to avoid
overwriting a plot the user has previously made.
}
\details{
This is an utility function used by \link{four_panels} and
\link{plot_coverage}.
}
\examples{

## Choose a random PDF file
PDF <- paste0("test_", stats::runif(1, max = 1e10))

## Initially this works because the output PDF does not exist.
PDF <- check_pdf(PDF)
## It also adds the PDF extension if the user didn't supply it.
PDF

## Create a dummy PDF file
pdf(file = PDF)
plot(1, 1)
dev.off()

## Now it doesn't work since the PDF file already exists.
testthat::expect_error(
    check_pdf(basename(PDF)),
    "already exists! Rename or erase it"
)
}
\author{
Leonardo Collado-Torres
}
