Does R have a similarly smart division?

I've tried hard on:

> A/as.vector(as.matrix(ddLen))
Error in A/as.vector(as.matrix(ddLen)) : non-numeric argument to binary
operator

but failed...

Here my A is 10x10 matrix, and ddLen is a length-10 list of single numbers.

On 3/6/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
>
> The following are nearly identical to what others have already
> written but just in case:
>
> A - c(B)
>
> or
>
> A - B[,1]
>
> or if B were already a vector, b, in the first place, rather than a
> matrix:
>
> b <- 1:2
> A - b
>
>
>
> On 3/6/06, Michael <[EMAIL PROTECTED]> 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
> >
>

        [[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

Reply via email to