Rational Transformations
# S4 method for rationalS4 as.numeric(x, ...) # S4 method for rationalS4 as.integer(x, ...) # S4 method for rationalS4 as.character(x, ...) as.rationalS4(x, cycles = 10, max.denominator = 2000) # S4 method for numeric as.rationalS4(x, cycles = 10, max.denominator = 2000) # S4 method for character as.rationalS4(x, cycles = 10, max.denominator = 2000) as.rationalS3(x, cycles = 10, max.denominator = 2000) # S3 method for rationalS3 as.double(x, ...) # S3 method for rationalS3 as.integer(x, ...) as.rationalR6(x, cycles = 10, max.denominator = 2000) # S3 method for rationalR6 as.double(x, ...) # S3 method for rationalR6 as.integer(x, ...)
x | parameter to be transformed between classes |
---|---|
... | additional parameters passed to underlying methods |
cycles | The maximum number of steps to be used in the continued fraction approximation process |
max.denominator | If the denominator exceeds this number, the algorithm will stop with an approximation |
#> [1] 0.4 3.0#> [1] 0 3#> [1] 2#> [1] "2 / 5" "3 / 1"as.rationalS4(33.3)#> (333 / 10) = 33.3as.rationalS4("33.3")#> (333 / 10) = 33.3as.rationalS3(33.3)#> [1] "(333 / 10) = 33.3"#> [1] "(333 / 10) = 33.3" "(33 / 10) = 3.3"#> [1] 0.3333333#> [1] 0.3333333 0.4000000#> [1] 0.3333333#> [1] 0.3333333 0.4000000#> [1] 0#> [1] 0 0as.rationalR6(33.3)#> [1] "(333 / 10) = 33.3"#> [1] "(333 / 10) = 33.3" "(33 / 10) = 3.3"#> [1] 0.3333333#> [1] 0.3333333 0.4000000#> [1] 0.3333333#> [1] 0.3333333 0.4000000#> [1] 0#> [1] 0 0