From Treil's Linear Algebra Done Wrong:
Apply Gram-Schmidt orthogonalization to the system of vectors $(1,2,3)^T, (1, 3, 1)^T$. Write the matrix of the orthogonal projection onto $2$-dimensional subspace spanned by these vectors.
Using Gram-Schmidt, I found an orthogonal basis to be $$\left\{(1,2,3), \left(\frac{2}{7}, \frac{11}{7}, -\frac{8}{7}\right)\right\}.$$
If I define the map $$T{\bf x}= \frac{({\bf x},{\bf v}_1)}{\|{\bf v}_1\|^2}{\bf v}_1+\frac{({\bf x},{\bf v}_2)}{\|{\bf v}_2\|^2}{\bf v}_2$$ and then find where the basis vectors of $\mathbb R^3$ map to, I believe can find the matrix. But this is a mess.
Is there an easier way?
Faster way with $A=[v_1\, v_2]$
see here for the proof Writing projection in terms of projection matrix