[R] building random matrices from vectors of random parameters
Evan Cooch
evan.cooch at gmail.com
Thu Sep 28 15:14:08 CEST 2017
>
> In fact, this is what is returned by the mapply approach, while the
> array approach returns the transpose. I gather the 'missing step' is
> to use aperm, but haven't figured out how to get that to work...yet.
ms <- array(c(rep(0, 3),sa*m,so,sa), c(3, 2, 2))
ms_new <- aperm(ms,c(1,3,2));
for (i in 1:n) { print(ms_new[i,,]) }
[,1] [,2]
[1,] 0.0 0.96
[2,] 0.5 0.80
[,1] [,2]
[1,] 0.0 0.96
[2,] 0.5 0.80
[,1] [,2]
[1,] 0.0 0.96
[2,] 0.5 0.80
>
>
> On 9/28/2017 5:11 AM, Duncan Murdoch wrote:
>> ms <- array(c(rep(0, 5),sa*m,so,sa), c(5, 2, 2))
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list