A function $f:\Bbb R^n\to\Bbb R^m$ is said that maps convex sets on convex sets if it satisfies: (1) the image $f(A)$ of any convex set $A$ is a convex set; (2) the preimage $f^{-1}(B)$ of any convex set $B$ is a convex set. All affine transformations are examples of such functions.
My question is the following: if $f:\Bbb R^n\to\Bbb R^m$ maps convex sets on convex sets and $f(\Bbb R^n)$ is a subspace of $\Bbb R^m$, is $f$ an affine transformation?
Thanks for your help.
Addendum: I'm interested in the case $n,m>1$. I apologize for not specifying this before.