Re: [R] 'combinations' in gtools and stack overflow
On Mon, 14 Feb 2005, Ho-Joon Lee wrote: Dear R-users, Let me ask about the 'stack overflow' error which I got when I used the function 'combinations' in gtools. The following is what I did: - library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow - How can I overcome this error? Is there perhaps any other function to do this more efficiently? R --help lists a flag that you can use to increase the size of the protect stack. It is also described in `An Introduction to R'. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 'combinations' in gtools and stack overflow
The documentation for 'combinations' explicitly describes this problem: Details: Caution: The number of combinations and permutations increases rapidly with 'n' and 'r'!. To use values of 'n' above about 45, you will need to increase R's recursion limit. See the 'expression' argument to the 'options' command for details on how to do this. and gives an example of the solution: # To use large 'n', you need to change the default recusion limit options(expressions=1e5) cmat - combinations(300,2) dim(cmat) # 44850 by 2 -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Prof Brian Ripley Sent: Monday, February 14, 2005 10:23 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Subject: Re: [R] 'combinations' in gtools and stack overflow On Mon, 14 Feb 2005, Ho-Joon Lee wrote: Dear R-users, Let me ask about the 'stack overflow' error which I got when I used the function 'combinations' in gtools. The following is what I did: - library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow - How can I overcome this error? Is there perhaps any other function to do this more efficiently? R --help lists a flag that you can use to increase the size of the protect stack. It is also described in `An Introduction to R'. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 'combinations' in gtools and stack overflow
combn in package combinat does not use recursion, and so may be simpler to use and may be able to do larger sets. David L. Reiner -Original Message- From: Warnes, Gregory R [mailto:[EMAIL PROTECTED] Sent: Monday, February 14, 2005 11:01 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Subject: RE: [R] 'combinations' in gtools and stack overflow The documentation for 'combinations' explicitly describes this problem: Details: Caution: The number of combinations and permutations increases rapidly with 'n' and 'r'!. To use values of 'n' above about 45, you will need to increase R's recursion limit. See the 'expression' argument to the 'options' command for details on how to do this. and gives an example of the solution: # To use large 'n', you need to change the default recusion limit options(expressions=1e5) cmat - combinations(300,2) dim(cmat) # 44850 by 2 -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Prof Brian Ripley Sent: Monday, February 14, 2005 10:23 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Subject: Re: [R] 'combinations' in gtools and stack overflow On Mon, 14 Feb 2005, Ho-Joon Lee wrote: Dear R-users, Let me ask about the 'stack overflow' error which I got when I used the function 'combinations' in gtools. The following is what I did: - library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow - How can I overcome this error? Is there perhaps any other function to do this more efficiently? R --help lists a flag that you can use to increase the size of the protect stack. It is also described in `An Introduction to R'. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE\ Unless expressly stated otherwise, this\ messa...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 'combinations' in gtools and stack overflow
Thank you for your replies, David and Brian. The function 'combn' in the package combinat works really fine without using any particular options. Thanks a lot again for referring me to the package, David. On the other hand, I do not know the meaning of stack overflow technically and am not interested in that. It was the first time that I got the error. But I am now, thanks to Brian, able to handle it by starting R with the following command-line option: --max-ppsize=10, which is described in Appendix B in 'An Introduction to R'. This is the only thing I can find in the material about 'stack'. Kind regards, Lee Prof Brian Ripley wrote: On Mon, 14 Feb 2005, Ho-Joon Lee wrote: Dear R-users, Let me ask about the 'stack overflow' error which I got when I used the function 'combinations' in gtools. The following is what I did: - library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow - How can I overcome this error? Is there perhaps any other function to do this more efficiently? R --help lists a flag that you can use to increase the size of the protect stack. It is also described in `An Introduction to R'. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] 'combinations' in gtools and stack overflow
On Mon, 14 Feb 2005, Warnes, Gregory R wrote: The documentation for 'combinations' explicitly describes this problem: Not so: this is misinformation send in reply to correct and helpful comments. Details: Caution: The number of combinations and permutations increases rapidly with 'n' and 'r'!. To use values of 'n' above about 45, you will need to increase R's recursion limit. See the 'expression' argument to the 'options' command for details on how to do this. and gives an example of the solution: # To use large 'n', you need to change the default recusion limit options(expressions=1e5) cmat - combinations(300,2) dim(cmat) # 44850 by 2 Let me repeat for you what he said he did: library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow Do you notice the second line there this time around? The message is not about the number of expressions, but about the sizd of the protect stack. R --max-ppsize=5 allows combinations(400, 2, 1:400) to work, as I correctly suggested. -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Prof Brian Ripley Sent: Monday, February 14, 2005 10:23 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Subject: Re: [R] 'combinations' in gtools and stack overflow On Mon, 14 Feb 2005, Ho-Joon Lee wrote: Dear R-users, Let me ask about the 'stack overflow' error which I got when I used the function 'combinations' in gtools. The following is what I did: - library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow - How can I overcome this error? Is there perhaps any other function to do this more efficiently? R --help lists a flag that you can use to increase the size of the protect stack. It is also described in `An Introduction to R'. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] 'combinations' in gtools and stack overflow
Yes, 'combn' is much simpler to use than 'combinations'. Although Greg's 'combinations' is useful as well, 'combn' didn't produce the allocation error about vector size in my particular case. 'combn' works very well even in Windows. Thanks again, David. Lee [EMAIL PROTECTED] wrote: combn in package combinat does not use recursion, and so may be simpler to use and may be able to do larger sets. David L. Reiner -Original Message- From: Warnes, Gregory R [mailto:[EMAIL PROTECTED] Sent: Monday, February 14, 2005 11:01 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Subject: RE: [R] 'combinations' in gtools and stack overflow The documentation for 'combinations' explicitly describes this problem: Details: Caution: The number of combinations and permutations increases rapidly with 'n' and 'r'!. To use values of 'n' above about 45, you will need to increase R's recursion limit. See the 'expression' argument to the 'options' command for details on how to do this. and gives an example of the solution: # To use large 'n', you need to change the default recusion limit options(expressions=1e5) cmat - combinations(300,2) dim(cmat) # 44850 by 2 -Greg -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Prof Brian Ripley Sent: Monday, February 14, 2005 10:23 AM To: Ho-Joon Lee Cc: r-help@stat.math.ethz.ch Subject: Re: [R] 'combinations' in gtools and stack overflow On Mon, 14 Feb 2005, Ho-Joon Lee wrote: Dear R-users, Let me ask about the 'stack overflow' error which I got when I used the function 'combinations' in gtools. The following is what I did: - library(gtools) options(expressions=1e5) combinations(500, 3, 1:500) # or combinations(400, 2, 1:400) Error: protect(): stack overflow - How can I overcome this error? Is there perhaps any other function to do this more efficiently? R --help lists a flag that you can use to increase the size of the protect stack. It is also described in `An Introduction to R'. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html