as_decimal: Convert a Fraction to a Decimal

Description Usage Arguments Value Examples

View source: R/fractions.R

Description

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

Usage

1
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

1
2
3
4
5
6
# String as input
as_decimal("2 3/8")

# Parsed fraction as input
x <- as_improper("-1 1/3")
as_decimal(x)

mrdwab/mathrrr documentation built on July 20, 2020, 11:14 p.m.