Re: [R] Error in rep.int() invalid 'times' value

2015-10-21 Thread marammagdysalem
0 0 0 >> all.equal(b,bb) > [1] TRUE > > So the time gain is huge only in this small computation. > > Cheers > Petr > >> -Original Message- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maram >> SAlem >>

Re: [R] Error in rep.int() invalid 'times' value

2015-10-21 Thread PIKAL Petr
this small computation. Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maram > SAlem > Sent: Tuesday, October 20, 2015 6:33 PM > To: William Dunlap > Cc: r-help@r-project.org > Subject: Re: [R] Error in rep.int() invalid '

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
Yes Indeed William. f1() works perfectly well and took only 30 secs to execute f1(25,15), but I wonder if there is anyway to speed up the execution of the rest of my code (almost seven hours now) ? Thanks for helping. Maram Salem On 20 October 2015 at 18:11, William Dunlap wrote: > f0 is essen

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread William Dunlap
f0 is essentially your original code put into a function, so expect it to fail in the same way your original code did. f1 should give the same answer as f0, but it should use less memory and time. Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Oct 20, 2015 at 2:05 AM, Maram SAlem wrote: >

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
duced by coercion to integer range > > > > > res1<-f1(25,15) > > > > So f1 works for required m,n. > > > > William just used different approach to get the same result, which is > indeed quite common in R. > > > > Cheers > > Petr > > &

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread PIKAL Petr
) So f1 works for required m,n. William just used different approach to get the same result, which is indeed quite common in R. Cheers Petr From: Maram SAlem [mailto:marammagdysa...@gmail.com] Sent: Tuesday, October 20, 2015 1:50 PM To: PIKAL Petr Cc: r-help@r-project.org Subject: Re: [R] Error in

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
econd function f1 which William suggested? > > Cheers > Petr > > > > -Original Message- > > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Maram > > SAlem > > Sent: Tuesday, October 20, 2015 11:06 AM > > To: William Dunlap;

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread PIKAL Petr
t; Subject: Re: [R] Error in rep.int() invalid 'times' value > > Thanks William. I've tried the first code, ( with f0() ), but still for > n=25, m=15 , I got this: > > > s<-f0(25,15) > Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : >

Re: [R] Error in rep.int() invalid 'times' value

2015-10-20 Thread Maram SAlem
Thanks William. I've tried the first code, ( with f0() ), but still for n=25, m=15 , I got this: > s<-f0(25,15) Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : invalid 'times' value In addition: Warning message: In rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) :

Re: [R] Error in rep.int() invalid 'times' value

2015-10-16 Thread marammagdysalem
Thanks a lot for helping William. Will check the reference as well. Sent from my iPhone > On Oct 15, 2015, at 5:52 PM, William Dunlap wrote: > > Doing enumerative combinatorics with rejection methods rarely > works well. Try mapping your problem to the problem of choosing > m-1 items from n-1.

Re: [R] Error in rep.int() invalid 'times' value

2015-10-15 Thread William Dunlap
Doing enumerative combinatorics with rejection methods rarely works well. Try mapping your problem to the problem of choosing m-1 items from n-1. E.g., your code was f0 <- function(n, m) { stopifnot(n > m) D<-matrix(0,nrow=n-m+1,ncol=m-1) for (i in 1:m-1){ D[,i]<-seq(0,n-m,1) }

[R] Error in rep.int() invalid 'times' value

2015-10-15 Thread Maram SAlem
Dear All, I'm trying to do a simple task (which is in fact a tiny part of a larger code). I want to create a matrix, D, each of its columns is a sequence from 0 to (n-m), by 1. Then, using D, I want to create another matrix ED, whose rows represent all the possible combinations of the elements of