A general function is simply a mapping, and the suggestion in your drawing can do that almost verbatim in any language:
$ \begin{eqnarray} R(1) &=& 2;\\ R(2) &=& 3;\\ R(3) &=& 4;\\ R(4) &=& 1;\\ R(5) &=& 2;\\ R(6) &=& 4;\\ \end{eqnarray} $
That is, (in C style)
R(x) = (x==1) ? 2 : (x==2) ? 3 : (x==3) ? 4 : (x==4) ? 1 : (x==5) ? 2 : 4;
You could create a function for L, U, D, too (and presumably O for opposite), and this would work for any labeling. Note though that you should have a preferred orientation for each face/label (so that you can't rotate the cube keeping the same face forward). This you already knew.
What you are seeking is a labeling such that you can have a simpler function and corresponding labeling that fits, one that does not involve laboriously listing out the assigned values for each function and face. For some reason a case-by-case version is just not as elegant as a pre-calculus function. For example, to mimic the above function for $R$ and your labeling, you might use:
$ \begin{eqnarray} R(x) &=& (x \bmod 4) + 1\\ L(x) &=& (x-2 \bmod 4) + 1\\ U(x) &=& 5\\ D(x) &=& 6\\ \end{eqnarray} $ (note that the range of mod is from 0 to 3).
These functions work very well for $x=1,2,3,4$ but not at all when $x=5,6$.
The difficulty as you've probably already noticed is how to assign labels and some other functions so that $U$ and $D$ are likewise easy to compute so that it will work for $x=5$ and $x=6$ too.
Again, one could use an arbitrary labeling and for each function come up with a polynomial that fits all 6 values. Suppose $R(5) = 2$ and $R(6) = 4$.
Lagrange Interpolation is a one possible technique that already does this. For $n$ $x,y$ points you fit an $n-1$ degree polynomial to get
$ \begin{eqnarray} R(x) &=& 2\cdot\frac{(x-2)(x-3)(x-4)(x-5)(x-6)}{(1-2)(1-3)(1-4)(1-5)(1-6)}\\ &+& 3\cdot\frac{(x-1)(x-3)(x-4)(x-5)(x-6)}{(2-1)(2-3)(2-4)(2-5)(2-6)}\\ &+& 4\cdot\frac{(x-1)(x-2)(x-4)(x-5)(x-6)}{(3-1)(3-2)(3-4)(3-5)(3-6)}\\ &+& 1\cdot\frac{(x-1)(x-2)(x-3)(x-5)(x-6)}{(4-1)(4-2)(4-3)(4-5)(4-6)}\\ &+& 2\cdot\frac{(x-1)(x-2)(x-3)(x-4)(x-6)}{(5-1)(5-2)(5-3)(5-4)(5-6)}\\ &+& 4\cdot\frac{(x-1)(x-2)(x-3)(x-4)(x-5)}{(6-1)(6-2)(6-3)(6-4)(6-5)}\\ \end{eqnarray} $
(notice the cancellation of all terms to either 0 or 1) and after a lot of tedious calculation and simplification (or rather after Mathematica does it), you get:
$R(x) = \frac{1}{120} (4800 - 10062 x - 7755 x^2 - 2635 x^3 - 405 x^4 - 23 x^5)$
Using Zhen Lin's suggestion in the comment, one can take this mod 7 to get more manageable coefficients:
$R(x) = (5 + 4 x + 6 x^2 + 4 x^3 + 6 x^4 + 5 x^5) \bmod 7$
So two things to note...not only was that calculation tedious (just checking it is intractable by hand (more than it's worth)), but the resulting function is not particularly nice, and looks even more complex than just the plain old list.
At this point, maybe we could find a simpler function for a particular idiosyncratic labeling like Qiaochu's, using mod or some other simple functions, and it might even be simpler to do the finding, but I have no flash of insight right yet that it would allow it to work for all faces.
So I think the moral of the story is that, really, the easiest thing to code (and also quickest to execute, and easiest to understand later) will be the 'list-of-values' function.
The desire for a non-case based function is a natural one, like capturing a recurrence relation with a generating function, or fitting a function to a set of points. But in this case the result is as or more complex than the simple list.