convert_to_unit()
allows you to convert a numerical object to different
kind of units.
See the Units section for more information about the units that
convert_to_unit()
can handle.
Arguments
- x
A
numeric
object.- from
A string indicating the unit of
x
(see the Units section to learn more) (default:"seconds"
).- to
(optional) a string indicating the desire output unit (see the Units section to learn more) (default:
"hours"
).
Value
A numeric
object representing the decimals
hours x
.
Units
Here are the units that convert_to_unit()
can handle for now:
years.
weeks.
days.
hours.
minutes.
seconds.
milliseconds.
microseconds.
nanoseconds.
degrees.
radians.
Examples
convert_to_unit(60, "seconds", "minutes")
#> [1] 1
#> [1] 1
convert_to_unit(1, "minute", "hours")
#> [1] 0.01666667
#> [1] 0.01666667
convert_to_unit(1, "hour", "days")
#> [1] 0.04166667
#> [1] 0.0416666
convert_to_unit(1, "day", "weeks")
#> [1] 0.1428571
#> [1] 0.1428571
convert_to_unit(7, "days", "weeks")
#> [1] 1
#> [1] 1
convert_to_unit(1, "week", "days")
#> [1] 7
#> [1] 7