rnorm_pre Produces a random normally distributed vector with the specified correlation to an existing vector

rnorm_pre(x, rho = 0, ymean = 0, ysd = 1)

Arguments

x

the existing vector

rho

desired correlation between existing and returned vectors

ymean

desired mean of returned vector

ysd

desired SD of returned vector

Value

vector

Examples

v1 <- rnorm(10) v2 <- rnorm_pre(v1, 0.5, 0, 1) cor(v1, v2)
#> [1] 0.5