The as_decimal function parses a string and evaluates the result to return a numeric approximation.

as_decimal(fraction)

Arguments

fraction

The input fraction, already parsed, or a string to be parsed using parse_fraction(fraction, improper = TRUE, reduce = TRUE).

Value

A numeric (possible approximation) of the fraction converted to a numeric value.

Examples

# String as input as_decimal("2 3/8")
#> [1] 2.375
# Parsed fraction as input x <- as_improper("-1 1/3") as_decimal(x)
#> [1] -1.333333