I would like to prove that the fundamental group of the subspace $X$ of $\mathbb{R}^{2}$ is isomorphic to $\mathbb{Z}$.
$X=([-1,1]\times[0,2))\cup\mathbb{S}^{1}$. I have defined the following retraction:
$r(x,y)=\begin{cases} (x,y), \quad (x,y)\in \mathbb{S}^{1},\\ \frac{(x,y)}{||(x,y)||}, \quad (x,y)\in([-1,1]\times[0,2))\backslash([-1,1]\times\{0\}),\\ (-1,0), \quad (x,y)\in[-1,1]\times\{0\}. \end{cases}$
Is continuous (because of the pasting lemma (1) ), $r\circ i=Id_{\mathbb{S}^{1}}$ and with the linear homotopy $H(x,t)=(1-t)x+tr(x)$ we have that $i\circ r\simeq Id_{X}$ (2).
So, we have $\pi_{1}(X,x)$ is isomorphic to $\pi_{1}(\mathbb{S}^{1})=\mathbb{Z}$.
Well, really I don't know how to justify (1), because, I have doubts in that the sets where I define the parts of my retraction are closed, and (2) because I only get that $r\simeq Id_{X}$ and not $i\circ r\simeq Id_{X}$.
Thanks to all the answers!
This retraction does not work, because your map is not continuous: $r(0,0)=(-1,0)$, but if $y>0$ then $r(0,y)=(0,1)$, so the limit of $r(0,y)$ as $y \to 0$ equals $(0,1)$, which is not equal to $r(0,0)=(-1,0)$.
The problem is trying to use the formula $\frac{(x,y)}{\|(x,y)\|}$, which one can think of as radial projection away from the origin to $S^1$, and which isn't going to work when the origin is in the domain $X$.
Instead, use radial projection away from some point which is not in the domain $X$. For example, I think that radial projection away from the point $(0,-\frac{1}{2})$ to $S^1$ should work just fine.