I'm not quite sure I understand the question:
Does this mean that in general the rank function is not continuous?
How general is "in general"? Anyway, here are some facts which taken together may answer your question.
1) A function $f$ from a topological space $X$ to a discrete space is continuous iff it is locally constant, i.e., for all $x \in X$ there exists a neighborhood $U$ of $x$ such that $f|_U$ is constant. For whatever reason, it is more common to speak of "locally constant" rank functions than continuous ones.
2) In order to have a rank function, an $R$-module $M$ must have the property that for all prime ideals $\mathfrak{p}$, the localization $M_{\mathfrak{p}}$ is finitely generated and free.
Certainly all the localizations will be finitely generated if $M$ itself is finitely generated (I'm blanking a little on conditions for the converse at the moment), so let's restrict to the case of finitely generated modules $M$.
3) For a finitely generated module $M$ with a well-defined rank function -- i.e., such that $M_{\mathfrak{p}}$ is free for all prime ideals $\mathfrak{p}$, the following are equivalent:
(i) The rank function is locally constant (equivalently, continuous).
(ii) $M$ is projective.
This takes some work: see e.g. $\S 13.9$ of my commutative algebra notes.
4) There are conditions on $R$ which force the rank function of any finitely generated locally free module to be constant: e.g. this holds if $R$ has a unique minimal prime ideal ($\S 13.9$), so in particular if $R$ is a domain. It also holds if $R$ is Noetherian ($\S 7.8$). However there are examples of finitely generated locally free modules with nonconstant rank function: see this MO question and its answer.