[R] filter on data frame

John Zhang jzhang at jimmy.harvard.edu
Wed Dec 11 20:09:02 CET 2002


Is this what you want?

> tt <- matrix(1:20, ncol = 4)
> tt
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   16
[2,]    2    7   12   17
[3,]    3    8   13   18
[4,]    4    9   14   19
[5,]    5   10   15   20
> tt[tt[,1] < 3, ]
     [,1] [,2] [,3] [,4]
[1,]    1    6   11   16
[2,]    2    7   12   17


>To: r-help at stat.math.ethz.ch
>From: AlessandroSemeria at cramont.it
>X-MIMETrack: Serialize by Router on ecom/twd(Release 5.0.6a |January 17, 2001) 
at 12/11/2002 07:26:51 PM
>MIME-Version: 1.0
>X-Virus-Scanned: by amavisd-milter (http://amavis.org/)
>X-Virus-Scanned: by amavisd-milter (http://amavis.org/)
>X-Spam-Status: No, hits=2.1 required=5.0 
tests=MAY_BE_FORGED,NO_REAL_NAME,SPAM_PHRASE_00_01 version=2.43
>X-Spam-Level: **
>Subject: [R] filter on data frame
>X-BeenThere: r-help at stat.math.ethz.ch
>X-Mailman-Version: 2.0.13
>List-Help: <mailto:r-help-request at stat.math.ethz.ch?subject=help>
>List-Post: <mailto:r-help at stat.math.ethz.ch>
>List-Subscribe: <http://www.stat.math.ethz.ch/mailman/listinfo/r-help>, 
<mailto:r-help-request at stat.math.ethz.ch?subject=subscribe>
>List-Id: Main R Mailing List: Primary help <r-help.stat.math.ethz.ch>
>List-Unsubscribe: <http://www.stat.math.ethz.ch/mailman/listinfo/r-help>, 
<mailto:r-help-request at stat.math.ethz.ch?subject=unsubscribe>
>List-Archive: <http://www.stat.math.ethz.ch/pipermail/r-help/>
>X-Original-Date: Wed, 11 Dec 2002 19:28:28 +0100
>Date: Wed, 11 Dec 2002 19:28:28 +0100
>
>Hello R-list.
>Someone know how to delete  rows on a char/num matrix
>following some criteria without a loop (something like: my.matrix[my.matrix
>[,4]<1e-5],
>but this one put within rows, that follow citeria, "NA")?
> Thanks!
>
>A.S.
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>http://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list