Hi Michael, 

Try: 

  A-as.vector(B)

Cheers, 

Anders. 

On Monday 06 March 2006 01:10 pm, Michael wrote:
> Hi all,
>
> I want to substract vector B from A's each column... how can R do
> that smartly without a loop?
>
> > A=matrix(c(2:7), 2, 3)
> > A
>
>      [,1] [,2] [,3]
> [1,]    2    4    6
> [2,]    3    5    7
>
> > B=matrix(c(1, 2), 2, 1)
> > B
>
>      [,1]
> [1,]    1
> [2,]    2
>
> > A-B
>
> Error in A - B : non-conformable arrays
>
>       [[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

______________________________________________
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

Reply via email to