For a simulation study I have to generate random variables that show a predefined (population) correlation to an existing variable $Y$.

I looked into the R packages copula and CDVine which can produce random multivariate distributions with a given dependency structure. It is, however, not possible to fix one of the resulting variables to an existing variable.

Any ideas and links to existing functions are appreciated!

 

Conclusion:
Two valid answers came up, with different solutions:


An R script by caracal, which calculates a random variable with an exact (sample) correlation to a predefined variable
An R function I found myself, which calculates a random variable with a defined population correlation to a predefined variable




[@ttnphns' addition: I took the liberty to expand the question title from single fixed variable case to arbitrary number of fixed variables; i.e. how to generate a variable having predefined corretation(s) with some fixed, existing variable(s)]

Here's another one: for vectors with mean 0, their correlation equals the cosine of their angle. So one way to find a vector $x$ with exactly the desired correlation $r$, corresponding to an angle $\theta$:


get fixed vector $x_1$ and a random vector $x_2$ 
center both vectors (mean 0), giving vectors $\dot{x}_{1}$, $\dot{x}_{2}$ 
make $\dot{x}_{2}$ orthogonal to $\dot{x}_{1}$ (projection onto
orthogonal subspace), giving $\dot{x}_{2}^{\perp}$ 
scale $\dot{x}_{1}$ and $\dot{x}_{2}^{\perp}$ to length 1, giving
$\bar{x}_{1}$ and $\bar{x}_{2}^{\perp}$ 
$\bar{x}_{2}^{\perp} +  (1/\tan(\theta)) \cdot \bar{x}_{1}$ is the vector whose angle to
$\bar{x}_{1}$ is $\theta$, and whose correlation with $\bar{x}_{1}$
thus is $r$. This is also the correlation to $x_1$ since linear
transformations leave the correlation unchanged.


Here is the code:

n     <- 20                    # length of vector
rho   <- 0.6                   # desired correlation = cos(angle)
theta <- acos(rho)             # corresponding angle
x1    <- rnorm(n, 1, 1)        # fixed given data
x2    <- rnorm(n, 2, 0.5)      # new random data
X     <- cbind(x1, x2)         # matrix
Xctr  <- scale(X, center=TRUE, scale=FALSE)   # centered columns (mean 0)

Id   <- diag(n)                               # identity matrix
Q    <- qr.Q(qr(Xctr[ , 1, drop=FALSE]))      # QR-decomposition, just matrix Q
P    <- tcrossprod(Q)          # = Q Q'       # projection onto space defined by x1
x2o  <- (Id-P) %*% Xctr[ , 2]                 # x2ctr made orthogonal to x1ctr
Xc2  <- cbind(Xctr[ , 1], x2o)                # bind to matrix
Y    <- Xc2 %*% diag(1/sqrt(colSums(Xc2^2)))  # scale columns to length 1

x <- Y[ , 2] + (1 / tan(theta)) * Y[ , 1]     # final new vector
cor(x1, x)                                    # check correlation = rho




For the orthogonal projection $P$, I used the $QR$-decomposition to improve numerical stability, since then simply $P = Q Q'$.
