Let $R$ be a (not necessarily commutative) ring and $M$ a free $R$-module of finite rank $n$. Suppose that $m_1, \dots, m_r$ is a spanning set of $M$. Does there exist $n$ elements among the $m_1, \dots, m_r$ that are linearly independent?
If not, are there nice conditions such that this turns true?
Of course, this is true for vector spaces. It seems to be true for PIDs R, though I do not have a proof for this.
Perhaps you'd like to have a look at this thread: https://mathoverflow.net/q/29993
And theses Wikipedia article: https://en.wikipedia.org/wiki/Free_module, https://en.wikipedia.org/wiki/Invariant_basis_number
If the given $R$ is not an $IBN$ ring, then chances are, $M$ does not have a well-defined rank in the sense of smallest amount of linear independent elements that generate $M$. Instead, $M$ would have different bases, sometimes having the same cardinality, sometimes different, and we would not talk about rank.