% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/nm_helpers.R
\name{nm_to_molar}
\alias{nm_to_molar}
\title{Convert NM Dataset from Mass to Molar Units}
\usage{
nm_to_molar(
  df,
  mw_dose,
  mw_dv = mw_dose,
  amt_cols = c("AMT", "RATE"),
  dv_col = "DV",
  cmt_col = "CMT",
  dose_factor = 1000,
  dv_factor = 1
)
}
\arguments{
\item{df}{data.frame.}

\item{mw_dose}{numeric scalar.  MW for AMT and RATE columns.}

\item{mw_dv}{numeric scalar OR named numeric.
Scalar: applied to all DV regardless of CMT.
Named: names are CMT values; rows whose CMT is not in names() are left
unchanged.  Default = mw_dose.}

\item{amt_cols}{columns to convert with mw_dose.  Default c("AMT", "RATE").}

\item{dv_col}{DV column.  Default "DV".}

\item{cmt_col}{CMT column.  Default "CMT".}

\item{dose_factor}{multiplier applied after AMT/RATE divided by mw_dose.
1000 = mg -> umol (default).}

\item{dv_factor}{multiplier applied after DV divided by mw_dv.
1 = ng/mL -> umol/L (default).}
}
\value{
data.frame with converted columns; other columns unchanged.
}
\description{
Convert AMT/RATE/DV columns of a NM data.frame from mass units to molar units.
}
\details{
Typical use:
\itemize{
  \item AMT, RATE in mg, DV in ng/mL, MW in g/mol
  \item mg / MW * 1000  ->  umol
  \item ng/mL / MW      ->  umol/L
}

For multiple analytes (e.g., parent at CMT=1 and metabolite at CMT=3),
supply \code{mw_dv} as a named numeric vector with names equal to the CMT
values (as character):  \code{c(`1` = 394.47, `3` = 380.47)}.
}
