Re: [R] make matrices as many as possible with a constraint

2014-12-11 Thread David Winsemius

On Dec 11, 2014, at 4:38 PM, Kathryn Lord wrote:

> Dear R users,
> 
> I'd like to make 4 by 7 matrices as many as possible with natural numbers 1
> through 28 such that each matrix have different elements of each column.

I was tempted to respond:

We're very sorry. The Soduko Challenge Contest was closed several years ago.

> 
> For example,
> 
> simply here is one
> 
>> a1 <- matrix(1:28, 4,7)
>> a1
> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
> [1,]159   13   17   21   25
> [2,]26   10   14   18   22   26
> [3,]37   11   15   19   23   27
> [4,]48   12   16   20   24   28
> 
> another one
> 
>> a2 <- matrix(1:28, 4,7, byrow=T)
>> a2
> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
> [1,]1234567
> [2,]89   10   11   12   13   14
> [3,]   15   16   17   18   19   20   21
> [4,]   22   23   24   25   26   27   28

What about: 

replicate(1000, list(matrix(sample(28), 4,7) ) )

Somebody ( but not me) will probably know the probability that "each matrix has 
different elements of each column" once you explain exactly what that phrase 
means to you. At the moment its not clear if a permutation of columns makes a 
matrix "different".

> 
> Matrices a1 and a2 have different columns, and I guess there are such many
> matrices.
> 
> Any suggestion will be greatly appreciated.
> 
> Best,
> 
> Kathryn Lord
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] make matrices as many as possible with a constraint

2014-12-11 Thread Kathryn Lord
Dear R users,

I'd like to make 4 by 7 matrices as many as possible with natural numbers 1
through 28 such that each matrix have different elements of each column.

For example,

simply here is one

> a1 <- matrix(1:28, 4,7)
> a1
 [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]159   13   17   21   25
[2,]26   10   14   18   22   26
[3,]37   11   15   19   23   27
[4,]48   12   16   20   24   28

another one

> a2 <- matrix(1:28, 4,7, byrow=T)
> a2
 [,1] [,2] [,3] [,4] [,5] [,6] [,7]
[1,]1234567
[2,]89   10   11   12   13   14
[3,]   15   16   17   18   19   20   21
[4,]   22   23   24   25   26   27   28

Matrices a1 and a2 have different columns, and I guess there are such many
matrices.

Any suggestion will be greatly appreciated.

Best,

Kathryn Lord

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.