[R] Solve for x in Ax=B with vectors, not matrices

Lapointe, Pierre Pierre.Lapointe at nbf.ca
Sun Jan 22 18:51:11 CET 2006


Hello R-helpers,

What I have: I am working with vectors not matrice:

#Basic equations
A <-c(-20,-9,-2)
x <-c(0.17,0.22,0.61)
B <- crossprod(A,x)

# R matrix multiplication works with vectors
A%*%x==B 	# Is true...

Question: If x is unknown and A and B are known, how do I solve for x in R?
solve(A,B) won't work because A is not a square matrix 

solve(A,B)
Error in solve.default(A, B) : 'A' (3 x 1) must be square

I understand that I might have many solutions but note that the sum of x is
1 and all x are positive (x are weightings in % of the total).

Regards,

Pierre Lapointe



*****************************************
AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{dropped}}




More information about the R-help mailing list