[R] Returning the coef from two coordinates
Petr Savicky
savicky at cs.cas.cz
Sun Apr 29 17:06:35 CEST 2012
On Fri, Apr 27, 2012 at 02:08:09PM -0700, Hans Thompson wrote:
> I meant (1,1) as an (x,y) coordinate. I am trying to find the function to
> return the coefficient of the line running through:
>
> >B
> x y
> a 1 1
>
> and all the points in:
>
> >A
> x y
> a 1 3
> b 2 2
> c 3 1
Hi.
If you want three coefficients, one for each point in A, then try
C <- sweep(A, 2, B)
C[, 2]/C[, 1]
[1] Inf 1 0
Petr Savicky.
More information about the R-help
mailing list