Hi, exist in any package a function which "work with sequences". Easy example 10 factors with 2 levels, are if i'm correct theoretical 2^10 "sequences" possible. But i have more than 2 levels and perhaps more than 10 factors and interested for the top10 "sequence's" with higehest freqs and wish to know which type of sequence it is. Many thanks for a starting point Christian
Not sure I completely understood what you want. If you have factors f1, f2, ..., fk with number of levels n1, n2, ..., nk, then there are n1 * n2 * ... * nk possible combinations (what you called sequences). Are you looking for the 10 combinations that appear most often in a data set? If so, I would concatenate the factors together into a character vector (each element would be a combination), then table() that, and look for the top 10. The names() of the output will correspond to the combinations. HTH, Andy> From: Christian Schulz > > Hi, > > exist in any package a function which "work with sequences". > > Easy example 10 factors with 2 levels, are if i'm > correct theoretical 2^10 "sequences" possible. > > But i have more than 2 levels and perhaps more than 10 factors and > interested for the top10 "sequence's" > with higehest freqs and wish to know which type of sequence it is. > > Many thanks for a starting point > Christian > > ______________________________________________ > 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 > >
Phil and Andy, many thanks for your help's! regrads,christian Phil Spector wrote:> Christian - > Perhaps this is what you are looking for: > > > dat = NULL > > for(i in 1:8)dat = cbind(dat,sample(1:5,size=100000,replace=TRUE)) > > dat = data.frame(dat) > > tt = table(dat) > > tt1 = data.frame(tt) > > tt1 = tt1[order(tt1[,9],decreasing=TRUE),] > > tt1[1:10,] > > Basically, converting the result from table() to a data frame > produces a data frame with one column for each factor, and a final > column with the counts. Reording the data frame by that final column > orders the sequences by their frequencies. > > Hope this helps! > > - Phil Spector > Statistical Computing Facility > Department of Statistics > UC Berkeley > spector at stat.berkeley.edu > > > On Thu, 9 Dec 2004, Christian Schulz wrote: > >> Hi, >> >> exist in any package a function which "work with sequences". >> >> Easy example 10 factors with 2 levels, are if i'm >> correct theoretical 2^10 "sequences" possible. >> >> But i have more than 2 levels and perhaps more than 10 factors and >> interested for the top10 "sequence's" >> with higehest freqs and wish to know which type of sequence it is. >> >> Many thanks for a starting point >> Christian >> >> ______________________________________________ >> 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 >> >