For the second question, remember that the subset only has to be closed in the irrationals, not as a subset of $\mathbb{R}$. With that in mind, here is a simple construction:
Ouryou can take the closed subset willto be the irrationals in $(-1,1)$ union some countable discrete set of irrationals outside this interval. On $(-1,0)$, define the function$f$ by $x\mapsto \frac{1}{x}+1$; on $(0,1)$, by $x\mapsto \frac{1}{x}-1$, and on the discrete set, choose some bijection with $\mathbb{Q}$.