What is the general procedure for solving systems of equations using R (as opposed to the manual exclusion of Gauss-Jordan / Gauss)?
Should I first determine if the system is defined / sub / redefined?
If a system is defined, I just use
solve(t(a)%*%a)%*%t(a)%*%b
to get $x$in$Ax = b$
If it is overridden or underdetermined, I'm not quite sure what to do. I think that the above sometimes gives an answer depending on the rank, but the solution is not always unique. How can I get all the solutions? I think if there is no solution, R will just give an error?
Context: I plan to recommend to my professor of stochastic calculus that we use R in our upcoming exam (as opposed to tedious calculators / calculations in manual mode), so I feel that only simple functions will be performed (e.g. solve) for over / underdetermined systems, not long programs / functions .
Edit: I tried to use solve(a,b), but I think it still does not give me all the solutions.
Here is an underdetermined example (R cannot give an answer since a is not a square):
a=matrix(c(1,1,1,3,2,1),byrow=T,nrow=2)
a
b=matrix(c(1,2),byrow=T,nrow=2)
b
solve(a,b)