This sequence of commands replicates your example, could you expand this to do what you want?
tmp <- c( outer( 0:4, 1:4, "/") ) tmp <- tmp[tmp <= 1] tmp <- unique(tmp) tmp <- sort(tmp) library(MASS) fractions(tmp)
[1] 0 1/4 1/3 1/2 2/3 3/4 1 Greg Snow, Ph.D. Statistical Data Center greg.snow at ihc.com (801) 408-8111
Robin Hankin <r.hankin at soc.soton.ac.uk> 03/04/05 07:06AM >>>
Hi
has anyone coded up Farey sequences?
[
The Farey sequence of order "n" is the set of rational numbers i/j
with (i,j)=1 such that 0 <= i,j <= n; the sequence is ordered from
lowest to highest.
Thus
Farey_4 = {0/1 , 1/4 , 1/3 , 1/2 , 2/3 , 3/4 , 1/1}
]
My motivation is unimodular transformations: I need to systematically
generate 2-by-2 integer matrices with determinant 1, and Farey
sequences
seem to be the best way to do this.
--
Robin Hankin
Uncertainty Analyst
Southampton Oceanography Centre
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html