Hi, Try: sapply(seq_len(ncol(A)),function(i) {indx <- which(A[,i]%in% max(A[,i])); A[,i][indx] <- B[,i]; A[,i]})
A.K. On Tuesday, October 29, 2013 10:16 AM, eliza botto <eliza_bo...@hotmail.com> wrote: Dear Users, I have two matrices, one with 12 rows and 124 columns(A) and the other with 1 row and 124 column(B). i want to replace the maximum value in all columns of A with each (single) column value of B. How can i do it?? Thanks indeed in advance, Eliza [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.