Since $RP^2$ is compact and connected, its continuous image in $R$ is a closed interval. Let $f$ be this map. Suppose $RP^1 = f^{-1}(c)$. If $c$ is in the interior of $[a,b]$ then $RP^2$ \ $RP^1$ is not connected. Hence $c=a$ or $c=b$. WLOG assume $c=a$. I next want to argue that $f$ achieving a minimum on $RP^1$ implies $df = 0$ on $RP^1$, hence not surjective.As this problem arose in the context of a differential topology problem, I am hesitant to conclude that all partial derivatives of $f$ are zero at $p$, hence $df_p$ is null. I feel that any reference to partial derivatives requires mention of a chart. Therefore, how, in the language of differential topology, would I rigorously phrase such a conclusion?
Since first posting this question, I have some new thoughts. As I said in a later comment, this is as the question appeared on a qualifying exam. I think $f$ has to be smooth as opposed to merely $C^1$ since the Regular Level Set Theorem can only be applied with a smooth function. If $f$ is smooth, then the tangent plane of $R$ at $c$ can be spanned by $\frac{\partial f}{ \partial x_i} \Big|_p$ and if $c$ is the minimal value $f$ achieves in $R$, then given any $v \in T_p RP^2$, curve $\gamma: [0,1] \mapsto RP^2$ such that $\gamma(0) = p$, and $\gamma'(0) = v$, then $\sum_i v_i \frac{\partial f}{ \partial x_i} \Big|_p = df_p(v) = (f \circ \gamma)'(0) = 0$, hence $\frac{\partial f}{ \partial x_i} \Big|_p = 0$ for every $i$?
Let your connected compact space be $S^1=\{(x,y)\,|\,x^2+y^2=1\}\subset{\mathbb R}^2$. The function $f(x,y):=x$ assumes its minimum on $S^1$ at the point $p:=(-1,0)$, but $\nabla f(x,y)\equiv(1,0)$ is $\ne{\bf 0}$ at $p$.
Your idea of a "compact connected space" has to be made more precise.