Hi R-users,  I have this code below and use some code from sn package for multivariate skew t (rmst) to generate a set of random numbers.  I try to do a looping to produce ârandâ for different values of degrees of freedom (degf). Actually, Iâm not sure how to specify the attribute for the rand. As we know, rand will give us a set of results + all the parameters used, so just wonder whether we can do the same for this iteration.  rand_skewt <- function(dt,degf,n) { t1   <- length(degf)  rand <- matrix(dt,nrow=n)  xi   <- colMeans(dt)  Omega <- var(dt)  alpha <- skew(dt,na.rm = TRUE)  for (i in 1:t1) { rand[i] <- rmst(n,xi, Omega, alpha, df=degf[i])[1:n,1:2] }   rand }  dt <- yypos[1:10,]; degf <- c(4,4.5,5,6); n <- 5 > yypos[1:10,]       [,1] [,2]  [1,] 49.7 23.4  [2,] 141.6 136.8  [3,] 119.7 141.5  [4,] 27.2 47.2  [5,] 56.0 20.6  [6,] 58.1 62.4  [7,] 59.2 28.2  [8,] 22.8 22.4  [9,] 28.0 48.6 [10,] 69.9 85.2  rand_skewt(dt,degf,n)  this is the output I got, but I think something is incorrectâ¦By right every rand will have n by 2 matrixâ¦I only have this⦠ > rand_skewt(dt,degf,n)          [,1] [,2] [,3] [,4] [1,] 97.53849 58.1 23.4 62.4 [2,] 96.79773 59.2 136.8 28.2 [3,] 155.26630 22.8 141.5 22.4 [4,] 57.34792 28.0 47.2 48.6 [5,] 56.00000 69.9 20.6 85.2 Warning messages: 1: In rand[i] <- rmst(n, xi, Omega, alpha, df = degf[i])[1:n, 1:2] :  number of items to replace is not a multiple of replacement length 2: In rand[i] <- rmst(n, xi, Omega, alpha, df = degf[i])[1:n, 1:2] :  number of items to replace is not a multiple of replacement length 3: In rand[i] <- rmst(n, xi, Omega, alpha, df = degf[i])[1:n, 1:2] :  number of items to replace is not a multiple of replacement length 4: In rand[i] <- rmst(n, xi, Omega, alpha, df = degf[i])[1:n, 1:2] :  number of items to replace is not a multiple of replacement length   Thank you so much for any help given.  Regards.
[[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.