Saturday, 15 June 2013

Getting numerator and denominator of a fraction in R -



Getting numerator and denominator of a fraction in R -

using function fractions in library mass, can convert decimal fraction:

> fractions(.375) [1] 3/8

but how extract numerator , denominator? help fractions mentions attribute "fracs", can't seem access it.

a character representation of fraction stored in attribute:

x <- fractions(0.175) > strsplit(attr(x,"fracs"),"/") [[1]] [1] "7" "40"

r fractions

No comments:

Post a Comment