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]) } }
Thanks in advance! 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 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.