On Hartshorne's book of algebraic geometry, exercise 2.11 (c) page 13 it's ask to prove that for any two linear varieties $Y,Z$ in $P^n$, with $dim Y=r$, $dim Z=s$, if $r+s-n\geq 0$, then $Y\cap Z\neq \emptyset$, then $Y\cap Z$ is a linear variety of dimention $\geq r+s-n$.
I'm wondering if it can be taken to the affine variety: is there an example of $Y,Z\subset A^n$ affine varieties such that an irreducible component of $Y\cap Z$ has dimention $\geq r+s-n$?
Any suggestion is appreciated
If we take your question exactly as it's written, then taking $X=Y$ of dimension $r$, we get an example as long as $\frac{n}{2} \leq r \leq n$ since we then only require $r \leq n$. However, I don't think you mean to ask whether there are examples where this inequality holds in $\mathbb{A}^n$; I think you mean to ask whether it must always hold in the affine setting.
One main difference between $\mathbb{A}^n$ and $\mathbb{P}^n$ is that any two (linear) hyperplanes in $\mathbb{P}^n$ intersect, whereas in $\mathbb{A}^n$ we can have `parallel' linear hyperplanes which do not intersect.
For instance, taking $Y=\{x=0\}$ and $Z=\{x=1\}$ in $\mathbb{A}^2$, we have $\dim Y = \dim Z = 1$, but $Y\cap Z = \emptyset$. Similar results hold for $\{z=0\}, \{z=1\}$ in $\mathbb{A}^3$.