When calculating a proportion (0 < x < 1) I am looking to convert that result x into it's nearest 1/r form, so that for example for
x = 0.30 is converted into 1/3
whereas for
x = 0.29 is converted into 1/4
I have been trying different ideas using round() and fractions() from MASS with little success.
What would be your most simple solution in R that could make this work?