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