[R] Put submatrices in an array
Pascal Oettli
kridox at ymail.com
Tue Oct 30 08:53:04 CET 2012
Hello,
According to your script, the dimension of AA should be 16x3x161051.
Best Regards,
Pascal
Le 30/10/2012 16:30, Haris Rhrlp a écrit :
> Dear R users,
>
> I have a Hadamard matrix 16x15 and i want to put 16x5 submatrices in an array put i have an error.
>
>> A1<-matrix(c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
> + 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
> + 0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,
> + 1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,
> + 0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,
> + 1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,
> + 0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,
> + 1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,
> + 0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
> + 1,0,1,0,1,1,0,1,0,1,0,1,0,0,1,
> + 0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,
> + 1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,
> + 0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,
> + 1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,
> + 0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,
> + 1,1,0,1,0,1,0,1,0,0,1,0,1,0,1),ncol=15,byrow=T)
>> AA<-array(rep(0,240240),dim=c(16,5,3003))
>> n<-0
>>
>>
>> for (i in 1:11) {
> + for (j in 2:12) {
> + for (k in 3:13) {
> + for (l in 4:14) {
> + for (m in 5:15) {
> + n<-n+1
> + AA[,,n]<-cbind(A1[,i],A1[,j],A1[,k],A1[,l],A1[,m])
> + }
> + }
> + }
> + }
> + }
> Error in AA[, , n] <- cbind(A1[, i], A1[, j], A1[, k], A1[, l], A1[, m]) :
> subscript out of bounds
>
> Any help wil be welcome!!
>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list