Skip to content
Prev 301805 / 398506 Next

Remove a complete row as per the Range in a Matrix

Hello,

Please learn how to use dput(), it's not your first post.
And try the following.


myMatrix <- data.matrix(read.table(text="
Name            Age
ANTONY        27
IMRAN           30
RAJ                   22
NAHAS           32
GEO                 42
", header=TRUE))

MinMaxArray  <- data.frame(MIN = 25,MAX=35)

inx <- MinMaxArray[[ "MIN" ]] <= myMatrix[, "Age"] & myMatrix[, "Age"] 
<= MinMaxArray[[ "MAX" ]]
myMatrix[ inx , ]

Hope this helps,

Rui Barradas
Em 31-07-2012 08:58, Rantony escreveu: