Is this charge density function, from a problem in Griffiths' book, a physically valid density? This is from the book on electrodynamics by Griffiths:

A sphere of radius $R$, centered at the origin, carries charge density
  $$\rho(r,\theta)= k(R/r^2)(R-2r)\sin(\theta)$$
  where $k$ is constant, and $r$ and $\theta$ are usual spherical coordinates.

When the radius is $r=0$, what is value of $\theta$? We can not define $\theta$ there, since to define $\theta$ we need some finite (however small) displacement from the origin. Also, at $r=0$, the denominator is zero, and then $\rho$ will be infinite. So is this a valid (i.e. physically possible) density function?
 A: The important thing about a density is that its integral over any volume, which represents the total charge (or whatever it is a density of) inside that volume, is finite.
At $r=0$, $\theta$ is not defined since the polar coordinate chart for $\mathbb{R}^n$ covers everything but the origin. However, since the origin as a point is a set of zero Lebesgue measure, the value of any function at that single point does not contribute to any volume integral, so it is allowed to have a density that is not defined there.
Since the function $\rho(r,\theta)$ is integrated against the volume element1
$$\mathrm{d}V = r^2\sin(\phi)\mathrm{d}r\mathrm{d}\phi\mathrm{d}\theta$$
its integral over any volume will indeed be finite (as the worrisome $\frac{1}{r^2}$ term is cancelled), so the density is physically admissible.

1Hat tip to garyp, who pointed out the lack of the $r^2$ in a prior attempt to answer this question.
A: Firstly, no continuous charge density is perfect, a real charge density would jump up inside every nucleus and then go negative in between the nuclei.
But what is supposed to go on, is that if you average the charge over a region large enough to contain many atoms but small enough that the density of how many protons versus electrons isn't changing very much then replace the density at that point with the average in that region then you should get the kind of charge densities you want to call physical.
Secondly, don't worry about the angles at the origin. This is a problem of the coordinate system (the coordinate system is not defined there) not a problem of the charge density.
You could rewrite 
$$\rho(r,\theta,\phi)= k(R/r^2)(R-2r)\sin(\theta)$$
as
$$\rho(r,\theta,\phi)= k(R/r^3)(R-2r)r\sin(\theta)$$
And then as
$$\rho(x,y,z)= k\left(\frac{R^2-R\sqrt{x^2+y^2+z^2}}{(x^2+y^2+z^2)^{3/2}}\right)\sqrt{x^2+y^2}$$
and now all your concerns about angles are gone.

Also, at $r=0$, the denominator is zero, and then $\rho$ will be infinite. So is this a valid (i.e. physically possible) density function?

Sure, an infinite density requires seems to have an atom (with a finite charge) in an infinitesimally small region.
But really, what is a density? It is a thing you multiply by a little bit of volume to find out how much stuff is in a region. And when you pick a little finite bit of volume, and the mathematical density is different at different points in the volume then which value of the density are you supposed to choose. If the volume contains the origin it contains a whole (small) ball about the origin.  And we can compute the charge in such a ball
$$Q=\int_0^\epsilon\int_0^\pi\int_0^{2\pi}\rho(r,\theta,\phi)r^2\sin\theta d\phi d\theta dr$$
Which after we do the angular integrals gives
$$Q=\int_0^\epsilon \pi^2kR(R-2r)dr=\pi^2kR(R\epsilon-\epsilon^2)$$
Which is perfectly finite when $\epsilon$ is small.
