Extension of continuous map on metric space Let $X$ be a compact metric space, $A\subset X$ a closed subset and $f:A\to A$ be a continuous map.
Can $f$ be extended to a continuous map $X\to X$?
If so, is there an extension which is injective if $f$ is?
If not, are there handy additional conditions under which it holds?
 A: Consider $X = [0,1] \cup \{2\}$, $A = \{0,1,2\}$, and let $f:A \to A$ with $f(0)=0$, $f(1)=2$, $f(2)=0$.  For any extension  $g: X \to X$, $g([0,1])$ would not be connected so $g$ couldn't be continuous.
EDIT: For a more general class of examples, let $X = Y \times [0,1]$ and $A = Y \times \{0,1\}$ for some $Y$ such that the maps $y \mapsto f(y, 0)_1$ and $y \mapsto f(y,1)_1$ from $Y$ to $Y$ are not homotopic. 
A: Let $X = [0,3]$, $A$ is $X$ with $0$ removed, $f:A \to A$ is defined by $f(x) = 2+sin(1/x)$, then $f$ can't be extended to a continuous mapping from $X$ to $X$ simply because you can't define $f(0)$ without breaking continuity. 
A: Let $G = \langle a,b \mid R \rangle$ be a 1-relator group. To this presentation we obtain a twodimensional CW-complex $X$ by attaching a two cell to $S^1\vee S^1$ via the relator. Let $A=S^1\vee S^1$ be the one skeleton of $X$.
A continuous map $f:A\rightarrow A$ gives us two group elements in $\pi_1(X)=G$; the images of the generators $a,b$, i.e. the two circles in $A$. Any choice of pairs of group elements arises this way. Extending this map works only if the images satisfy the same relation, and this need not be the case. There are plenty of such one-relator groups.
If we choose for $f:A\rightarrow A$ the injective map that swaps the two circles, and our relator is not symmetric enough in $a,b$, there cannot be an extension of $f$.
