The R space is convenient for global functions like Fourier series etc. Consider
the following:
from fenics import *
n = 16
mesh = UnitIntervalMesh(n)
dim = 4
R = VectorFunctionSpace(mesh, "R", 0, dim=dim)
x = SpatialCoordinate(mesh)
omega = Constant(2.0*pi)
sinbasis = [sin((i+1)(omegax[0])) for i in range(dim)]
udofs = TrialFunction(R)
vdofs = TestFunction(R)
ubasis = [udofi * sini for udofi, sini in zip(udofs, sinbasis)]
vbasis = [vdofi * sini for vdofi, sini in zip(vdofs, sinbasis)]
u = sum(ubasis)
v = sum(vbasis)
a = inner(grad(u), grad(v))*dx(degree=4)
A = assemble(a)
print A.array()