Dear All, I have a fraction of 60./(220.*6.), which equals 1./22. My question is how to cancel the fraction so I actually get 1/22 (actually I just need the factor 22) using R. I tried it with prime factor decomposition from the package "schoolmath":
> require("schoolmath") Loading required package: schoolmath > nom <- prime.factor(60) > nom [1] 2 2 3 5 > denom <- prime.factor(220 * 6) > denom [1] 2 2 2 3 5 11 So far so good, now I just need to take all elements which are in nom out of denom (if possible). For this I use the package "sets", its function set_complement should exactly do that, but: > require(sets) > set_complement(nom, denom) {2, 2, 11} It gives me {2,2,11} and 2 * 2 * 11 is 44 and not 22. What am I doing wrong? Can anybody help me? Is there maybe a more elegant way to cancel a fraction than by prime factor decomposition? Many thanks in advance, Hannes -- View this message in context: http://r.789695.n4.nabble.com/cancelling-in-fraction-tp2062218p2062218.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.