Re: [R] Subset based on multiple values

2012-07-12 Thread arun
Hi, Try this: (a variant of andrija)  testct<-table(test)  subset(test,!is.na(match(test,as.integer(names(testct[testct%in%max(testct)])     [,1] [1,]    1 [2,]    1 [3,]    1 [4,]    1 [5,]    7 [6,]    7 [7,]    7 [8,]    7 A.K. - Original Message - From: Amanduh320 To: r-help@

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