Hello! I'm having trouble finding my error in the program below. I want to generate random values from a level vector, however I want my function to return an array of generated values. My program is returning an array, but the values of the columns are the same.
For a better understanding: I have 4 levels and I want to generate 10 values for each level. My intention is to get the program to return this array of values.
Program code
v = rep(0,4)
for(k in 1:length(v)){
rf = function(n,a,b,v)
{
u =runif(n,0,1)
x = (-log(u)) / (exp((b/v[k])-a))
return(matrix(x,n,length(v))
}
}
rf(10,-3,10,v=c(10,20,30,40))