Re: [R] Subset based on multiple values

2012-07-12 Thread arun
elp@r-project.org Cc: Sent: Wednesday, July 11, 2012 2:33 PM Subject: [R] Subset based on multiple values I'm stuck on a seemingly simple problem. I'm trying to subset the data by several numbers and it cuts out half of the rows. Here is the sample code: test <- as.matrix(c(1,1

Re: [R] Subset based on multiple values

2012-07-11 Thread Yasir Kaheil
yes just use %in% instead of == AllMax.. but also use table for count - Yasir Kaheil -- View this message in context: http://r.789695.n4.nabble.com/Subset-based-on-multiple-values-tp4636159p4636183.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Subset based on multiple values

2012-07-11 Thread Amanduh320
I want the output to be 1,1,1,1,7,7,7,7 The multiple values of AllMax are 1 and 7. I think I've figured it out though, I added a loop at the end: test <- as.matrix(c(1,1,1,1,3,3,7,7,7,7)) Count <- tapply(test[,1], test[,1], length) # count for each value spp <- unique(test[,1]) Count1 <- as.dat

Re: [R] Subset based on multiple values

2012-07-11 Thread andrija djurovic
Hi. Maybe this: ct <- table(test) as.numeric(names(ct[ct==max(ct)])) test[test[,1]%in%as.numeric(names(ct[ct==max(ct)])),,drop=FALSE] ? Andrija On Wed, Jul 11, 2012 at 8:33 PM, Amanduh320 wrote: > I'm stuck on a seemingly simple problem. I'm trying to subset the data by > several numbers and

Re: [R] Subset based on multiple values

2012-07-11 Thread Yasir
I see that this is your input: c(1,1,1,1,3,3,7,7,7,7) what do you want the output to be? what could the multiple values of AllMax be? - Yasir Kaheil -- View this message in context: http://r.789695.n4.nabble.com/Subset-based-on-multiple-values-tp4636159p4636167.html Sent from the R help mai

[R] Subset based on multiple values

2012-07-11 Thread Amanduh320
I'm stuck on a seemingly simple problem. I'm trying to subset the data by several numbers and it cuts out half of the rows. Here is the sample code: test <- as.matrix(c(1,1,1,1,3,3,7,7,7,7)) Count <- tapply(test[,1], test[,1], length) # count for each value spp <- unique(test[,1]) Count1 <- as.d