The only solution I found was x-t(mu) Is there a better way? Mike
On Wed, Dec 5, 2012 at 1:30 PM, C W <tmrs...@gmail.com> wrote: > Dear list, > I was curious how to subtract a vector from matrix? > > Say, I have > > mat <- matrix(1:40, nrow=20, ncol=2) > > x <-c(1,2) > > I want, > > x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements > of x against column elements in mat. > > But x-mat won't do it. > > Thanks, > > Mike > > [[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.