I'm trying to solve the following question:
Suppose $Y \subset R^n$ is a Euclidean neighborhood retract. I want to prove that if $Y$ is contractible, then it is a retract of $R^n$.
Let me solve the case of compact $Y$. Thus $Y$ is a contractible ANR. Then Y is an AR.
Indeed, the equivalence "contractible ANR $\Leftrightarrow$ AR" is a well known theorem, certainly known in the past to the founder of the theory of ANRs, Karol Borsuk. To prove this equivalence, consider an arbitrary compact metric space $X$, its closed subset $A$, and an arbitrary continuous map $f : A \rightarrow Y$, where $Y$ is a contractible ANR. Let $H:Y\times[0;1]\rightarrow Y$ be a contraction to a point $p\in Y$, meaning that $H(y\ 0)=p$ and $H(y\ 1)=y$ for every $y\in Y$. Now we get the constant map $g_0:X\rightarrow Y$, such that $\forall_{x\in X}\ g_0(x)=p$, and a homotopy $\Phi : A\times [0;1]\rightarrow Y$ defined by: $$\forall_{a\in A}\forall_{t\in [0;1]}\quad \Phi(a\ t) := H(f(a)\ t)$$ Observe that $\forall_{a\in A}\ \ g_0(a)=\Phi(a\ 0)$. Thus by the Borsuk homotopy extension theorem there exists a homotopy $F:X\times [0;1]\rightarrow Y$ such that
Now define $g_1:X\rightarrow Y$ by $\forall_{x\in X}\ \ g_1(x) := F(x\ 1)$. Then $g_1$ is a continuous extension of $f:A\rightarrow Y$ onto $X$. Thus we have proven that $Y$ is an AR.
It follows that $Y$ is a retract of the whole $\mathbf R^n$. Indeed, space $Y$--being an AR--is a retract of a cube $Q := [-\alpha;\alpha]^n$ which contains $Y$, while cube $Q$ is a retract of $\mathbf R^n$.
REMARK The last argument was simple, correct and adequate but ad hoc. Here is a more basic (general) argument: let compact $Y\subseteq \mathbf R^n$ be and AR (for metric compact spaces). The Euclidean space $\mathbf R^n$ is a subspace of a metric compact space $C$ (e.g. of $\mathbf R^n\cup\{\infty\} = \mathbf S^n$), and $Y$ is a retract of $C$, hence $Y$ is a retract of $\mathbf R^n$.
Observe that any retract of $\newcommand{\RR}{\mathbb{R}} \RR^n$ is necessarily a closed subspace of $\RR^n$. Assuming this necessary condition, the answer to the question is affirmative. More precisely, if $Y$ is a contractible ANR (absolute neighbourhood retract) and a closed subspace of $\RR^n$, then $Y$ is a retract of $\RR^n$. This is an instance of the following result.
Claim: Let $X$ be a metrizable ANR, and let $Y$ be an ANR and a closed subspace of $X$. If the inclusion of $Y$ into $X$ is a homotopy equivalence, then $Y$ is a retract of $X$.
This claim is an immediate consequence of the next two propositions.
Proposition 1: Let $X$ be a metrizable ANR, and let $Y$ be a closed subspace of $X$. If $Y$ is an ANR, then the inclusion of $Y$ into $X$ is a cofibration.
This is stated as proposition A.6.7 in the appendix to Fritsch and Piccinini's book "Cellular structures in topology", page 282. It is also stated and proved in Sze-Tsen Hu's 1965 book "Theory of retracts": see theorem 3.2 and corollary 3.3 on pages 120 and 121. Alternatively, you may look at the single lemma and its proof in this other answer, which gives proposition 1 for the case of ENRs.
Proposition 2: Assume $Y$ is a subspace of $X$ such that the inclusion of $Y$ into $X$ is a cofibration and a homotopy equivalence. Then $Y$ is a strong deformation retract of $X$; in particular, $Y$ is a retract of $X$.
This is a standard result in basic homotopy theory. For example, it is stated and proved as corollary 0.20 in chapter 0 of Allen Hatcher's book "Algebraic topology".