1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/conversion.R, R/mixed.R
\name{drop_units}
\alias{drop_units}
\alias{drop_units.units}
\alias{drop_units.data.frame}
\alias{drop_units.mixed_units}
\title{Drop Units}
\usage{
drop_units(x)
\method{drop_units}{units}(x)
\method{drop_units}{data.frame}(x)
\method{drop_units}{mixed_units}(x)
}
\arguments{
\item{x}{an object with units metadata.}
}
\value{
the numeric without any units attributes, while preserving other
attributes like dimensions or other classes.
}
\description{
Drop units attribute and class.
}
\details{
Equivalent to \code{units(x) <- NULL}, or the pipe-friendly version
\code{set_units(x, NULL)}, but \code{drop_units} will fail if the object has
no units metadata. Use the alternatives if you want this operation to succeed
regardless of the object type.
A \code{data.frame} method is also provided, which checks every column and
drops units if any.
}
\examples{
x <- 1
y <- set_units(x, m/s)
# this succeeds
drop_units(y)
set_units(y, NULL)
set_units(x, NULL)
\dontrun{
# this fails
drop_units(x)
}
df <- data.frame(x=x, y=y)
df
drop_units(df)
}
|