Linear transformation such that $T(x) = kx$, for all $x \in \mathbf{R^n}$ Question

Let $T : \mathbf{R^n} \rightarrow \mathbf{R^n}$ be a linear operator
  such that $T(W) \subseteq W$ for every subspace $W$ of $\mathbf{R^n}$.
  Show that there exists $k \in \mathbf{R}$ such that $T(x) = kx$, for all $x
\in \mathbf{R^n}$.

This is my attempt at an answer:
Let $\{e_1,\ldots, e_n\}$ be a basis of $\mathbf{R^n}$. Let W be the subspace generated by ${e_1}$. Then any element of W is of the form ${ke_1}$, for some $k \in \mathbf{R}$.
$\therefore T(e_1) \in W \Rightarrow T(e_1) = ke_1$ for some $k \in \mathrm{R}$. Similarly, $T(e_2) = ke_2,\ldots, T(e_n) = ke_n$
Every element $x$ of $\mathbf{R^n}$ is of the form $\alpha_1e_1 + \cdots  + \alpha_ne_n$, where $\alpha_1, \ldots ,\alpha_n \in \mathbf{R}$
$$\therefore T(x) = T(\alpha_1e_1 + \cdots + \alpha_ne_n)$$
$$= \alpha_1T(e_1) + \cdots + \alpha_nT(e_n)$$
$$= \alpha_1ke_1 + \cdots + \alpha_nke_n$$
$$= k(\alpha_1e_1 + \cdots + \alpha_ne_n)$$
$$= kx$$
I'm not sure if my proof is correct, especially the part in bold.
 A: You're right to be suspicious! Certainly $T(e_1) \in W \Rightarrow T(e_1) = ke_1$, but there's no (a priori) reason to know that $T(e_2) = ke_2$ with the same $k$. It could in general be the case that $T(e_2) = k_2 e_2$ instead, and similarly $T(e_3) = k_3 e_3$. 
So a correct approach could begin like yours, and say $T(e_1) = k_1 e_1$, $T(e_2) = k_2 e_2$, and so on. You now need to show that all the $k_i$ are equal which I'll leave to you, save for this hint: What happens if $W = \langle e_1 + e_2 \rangle$?
A: The problem with the attempted solution presented in the text of the question, especially the part in bold type, is that we can't assume 
$T(e_i) = ke_i, \tag 1$
with one value of $k \in \Bbb R$ for all the $e_i$; since all we are given is that
$T(W) \subset W \tag 2$
for any subspace $W$, there is nothing to a priori prohibit
$T(e_i) = k_i e_i, \tag 3$
with a different $k_i \in \Bbb R$ for each $e_i$; certainly an operator $T$ satisfying (3) has the property that
$T(\Bbb R e_i) \subset \Bbb R e_i \tag 4$
for each $e_i$.
So how can we force all the $k_i$ to be equal?  Well, suppose we look at the one dimenensional subspace $\Bbb R(e_i + e_j)$; since
$T(\Bbb R(e_i + e_j)) \subset \Bbb R(e_i + e_j), \tag 5$
there must be some $k \in \Bbb R$ with
$T(e_i + e_j) = k(e_i + e_j) = ke_i + ke_j; \tag 6$
but
$T(e_i + e_j) = T(e_i) + T(e_j) = k_i e_i + k_j e_j; \tag 7$
these two equations taken together yield
$ke_i + ke_j =  k_i e_i + k_j e_j, \tag 8$
whence
$(k - k_i)e_i + (k - k_j)e_j = 0; \tag 9$
the linear independence of the $e_i$ now forces
$k _i = k = k_j; \tag{10}$
since this argument applies for any two $e_i$, $e_j$, we must have
$k_i = k_j = k, \; \forall i, j \; 1 \le i, j \le n; \tag{11}$
we thus conclude that
$T = kI, \; k \in \Bbb R. \tag{12}$
It should of course be observed that the above argument applies for any basis $e_i$ of $\Bbb R^n$.
A: Let be $W_i=<e_i>$. From $T(e_i)\in W_i$, you can conclude that there exists $k_i\in \mathbb R$ such that $T(e_i)=k_ie_i$ because of the linearity of $T$. But you still have to prove that $k_1=\ldots=k_n$.
A: Yes it is almost correct but you need to prove that by linearity


*

*$T(e_i)=k_ie_i,\quad T(e_j)=k_je_j\implies k_i=k_j$


and also you should claim that the basis for any subspace $W$ can be expressed as linear combination of the vectors $e_i$ and then conclude.
A: No, your proof is not correct. Indeed, if $W=\langle e_1\rangle$, then there is a number $k_1$ such that $T(e_1)=k_1e_1$. And there is a number $k_2$ such that $T(e_2)=k_2e_2$. But you assumed, without proof, that $k_1=k_2$.
