Skip to content

request: most repeated sequnce

2 messages · Muhammad Azam, jim holtman

#
This may come closer since it removes the zeros before comparison:
+ 0,0,0,0,0,0,1,2,2,2,2,2,0,3,3,0,4,4,0,0,0,0,0,0)
+    rows <- table(apply(.mat,1,function(z){
+        # remove the zeros
+        z <- z[z != 0]
+        if (length(z) == 0) return(NULL)
+        paste(z,collapse=' ')
+    }))
+    names(rows[which.max(rows)])
+ })
[1] "1"       "1 2 3"   "1 2 3 4" "1 2 3 4" "2 2 3 4"

        
On Sat, Sep 6, 2008 at 12:48 PM, Muhammad Azam <mazam72 at yahoo.com> wrote: