In this question (How to show that for any abelian group $G$, $\text{Hom}(\mathbb{Z},G)$ is isomorphic to $G$), it is shown that $\operatorname{Hom}_\mathbb{Z}(\mathbb{Z},G)\cong G$, where $G$ is an abelian group (i.e. $\mathbb{Z}$-module).
When we generalize to $R$-modules, can we still say $$\operatorname{Hom}_R(R,G)\cong G ?$$ (isomorphic as $R$-modules)
($R$ is a commutative ring with 1, $G$ is an $R$-module).
I tried using the same isomorphism $\phi: \operatorname{Hom}_R(R,G)\to G$ defined by $f\mapsto f(1)$. It seems to work out; $\phi$ is an $R$-module homomorphism. It is injective since if $f(1)=0$, then $f(r)=rf(1)=0$ for all $r\in R$, so $f$ is the zero homomorphism. It is surjective since any for any $g\in g$, we can define a $f\in \operatorname{Hom}_R(R,G)$ such that $f(1)=g$, and then $f(r)=rf(1)=rg$ for any $r\in R$.
Is the above reasoning correct? Thanks.