0

I would like to find out the most frequent character in a big-data matrix .I m using table function to do this.When i got this character i would like to delete the rows that there is located and continue with the same procedure with the remaining rows .For example "

 m1<-matrix(c("a","b","a","c","b","a","a","a","c","c","b","a","a","b","b","c","b","a"),nrow=9,ncol=2,byrow = TRUE)
 temp <- table(as.vector(m1))
 t1<-names(temp)[temp == max(temp)]
 m2<-m1[rowSums(m1== t1[1]) == 0, ]
 temp2 <- table(as.vector(m2))
 t2<-names(temp2)[temp2 == max(temp2)]

When im using a big data matrix (i combine many big txt files) my system goes out of memory with the table function . Is there any way (package or function) to solve this ?

Unfortunately im not familiar wiith any package that requires special code .

i m using windows 7 64-bit 16gb ram

6
  • 1
    data.table package works pretty fast with large tables, not sure about memory
    – Andriy T.
    May 20, 2015 at 9:31
  • Thanks @ AndriyTkach for the reply .Unfortunately im not familiar wiith any package that requires special code ( i wiil add this information to my post) .In your suggestion , after loading the package i will only replace "table" with "data.table" ?
    – pshls
    May 20, 2015 at 10:06
  • Can you have the characters on a file and read it line by line? That way, you avoid the need to store all characters at once.
    – W7GVR
    May 20, 2015 at 10:20
  • @gvrocha ,if i understand your suggestion , I believe for export the most frequent character is necessary to store all of them in one table .
    – pshls
    May 20, 2015 at 10:53
  • @AndriyTkach : i just tested the data.table package ,i replace the "table" function and "t1" gives : Error in FUN(X[[1L]], ...) : only defined on a data frame with all numeric variables..............?
    – pshls
    May 20, 2015 at 11:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.