## Example
## Generate a correlation matrix with user-specified eigenvalues
set.seed(123)
R <- genCorr(c(2.5, 1, 1, .3, .2))
print(round(R, 2))
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.00 0.08 -0.07 -0.07 0.00
#> [2,] 0.08 1.00 0.00 -0.60 0.53
#> [3,] -0.07 0.00 1.00 0.51 -0.45
#> [4,] -0.07 -0.60 0.51 1.00 -0.75
#> [5,] 0.00 0.53 -0.45 -0.75 1.00
print(eigen(R)$values)
#[1] 2.5 1.0 1.0 0.3 0.2
Run the code above in your browser using DataLab