% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/units.R
\name{as.unit}
\alias{as.unit}
\title{Convert a String to a Unit}
\usage{
as.unit(u, default = list(unit = expression(), scale = ""))
}
\arguments{
\item{u}{a character string indicating a unit. Case is ignored, so that e.g.
\code{"dbar"} and \code{"DBAR"} yield equal results.  Many common notations are
recognized, e.g. \code{kg/m^3} and \verb{kg m-3} for density, etc.}

\item{default}{a default to be used for the return value, if \code{u}
is not a recognized string.  Setting this to NULL is a good way to
discover whether a given value of \code{u} is recognized as a unit
by this function, as opposed to something (like a conductivity
ratio) that simply has no unit.}
}
\value{
if \code{as.unit} recognizes \code{u} as unit, then it returns a list
with elements \code{unit}, which is an \code{\link[=expression]{expression()}}, and \code{scale},
which is a character value.  That is also the case if it does
not recognize \code{u}, and if \code{default} is not specified.  However,
if \code{u} is not recognized, and if \code{default} is provided by the user,
then \code{as.unit} returns the provided value of \code{default}.
}
\description{
This converts strings to unit objects.  It is designed mainly for
use within various functions in the package, not for the end user.
Therefore, the documentation does not give a full listing; for that,
developers should examine the \code{tests/test_that/test_units.R} file.
Developers who wish to add new entries are asked to follow
the conventions in this file, with regard to regular expressions,
spaces between tokens, etc., and also to add tests for whatever
they add.
}
\examples{
as.unit("DBAR")
as.unit("IPTS-68")
as.unit("ITS-90")
as.unit("PSS-78")
as.unit("UMOL/KG")

}
\author{
Dan Kelley
}
