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
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.
__
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
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
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
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
6 matches
Mail list logo