Message-ID: <43F20F94.2020608@statistik.uni-dortmund.de>
Date: 2006-02-14T17:12:52Z
From: Uwe Ligges
Subject: Inf values in a matrix
In-Reply-To: <OF0A6746A4.DE2E7FF1-ONC1257115.0057D370-C1257115.00580057@arz.co.at>
Ita.Cirovic-Donev at hypo-alpe-adria.com wrote:
>
>
>
> Hello,
>
> I have some Inf values in a matrix, but I don't want to replace them with
> some value but rather remove the rows that contain the Inf values. Also I
> would like to record the rows which were removed. Is there an easy way to
> do this instead of writing loops over the matrix? Thanks.
>
> Ita Cirovic Donev
>
> ______________________________________________
> 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
Example:
A <- matrix(1:100, 10)
A[cbind(3:4, 5:6)] <- Inf
recorded <- which(apply(A, 1, function(x) any(is.infinite(x))))
A[-recorded,]
Uwe Ligges