# Re: [R] replace values in a distance matrix

From: jim holtman <jholtman_at_gmail.com>
Date: Fri 28 Jul 2006 - 02:31:48 EST

M4.5[M4.5 < 4.5] <- 18

On 7/27/06, Mari Carmen Garcia Esteban <mc_gar_est@yahoo.es> wrote:
>
> Hi to everybody!
> I´m just a beginner in R, and I´m trying to replace values in a distance
> matrix with a concret condition: replace all values (elements) lower than
> 4.5 with value=18.
>
> I´ve tried this, but it doesn´t work...
>
> Dxy would be my 117 x 117 euclidean distance matrix
>
> M18 and M4.5 would be 117 x 117 matrices:
>
> M18<-matrix(rep(18,13689),nrow=117)
> M4.5<-matrix(rep(4.5,13689),nrow=117)
>
> REPLACE ALL VALUES >4.5 WITH 18.0 in Dxy
>
> for(i in 1:117) {
> for(j in 1:117) {
> Dxy[i,j]<-ifelse(Dxy[i,j]<M4.5[i,j],Dxy[i,j],M18[i,j])
> }
> }
>
>
>
> Mari Carmen Garcia
> Ud. Anatomía, Fisiologia y Génetica.
> Escuela Técnica Superior de Ingenieros de Montes de Madrid
> Spain.
>
>
>
>
>
> ---------------------------------
>
>
>
>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>

```--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help