[R] Select rows of matrix

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Mon Aug 20 15:03:47 CEST 2007


try this:

mat <- matrix(rnorm(20*10), 20, 10)
mat[sample(200, 10)] <- -Inf
mat
mat[apply(is.finite(mat), 1, all), ]


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
     http://www.student.kuleuven.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Van Wyk, Jaap" <jaapvw at uj.ac.za>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, August 20, 2007 2:36 PM
Subject: [R] Select rows of matrix


> Hi
>
> I would appreciate if anyone could help me with an elegant solution 
> of
> the following:
>
> I have a matrix that contain a small number of -Inf values.
>
> How can form a new matrix from the old one that excludes all the 
> rows
> with -Inf values ?
>
>
>
> Thank you.
>
> Jacob
>
>
>
> Dept of Statistics
>
> University of Johannesburg
>
> South Africa
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the R-help mailing list