There seems to be a limit to number of items that can be included in c() function in R (100 items). Is there any way to evade this limitation? Thanks in advance.
Asked
Active
Viewed 668 times
-8
-
5i don't think that's true.. can you provide an example? :) – Anthony Damico Jan 02 '13 at 00:21
-
3My guess is that this is a duplicate of these: http://stackoverflow.com/q/13059083/271616, http://stackoverflow.com/q/13216480/271616 – Joshua Ulrich Jan 02 '13 at 00:35
-
`dput(do.call(c, as.list(rep(letters, length.out=1e3))))` works fine – baptiste Jan 02 '13 at 00:36
-
1Dup. And -1 for minimal effort. Search on: [r] maximum length vector: http://stackoverflow.com/questions/10640836/max-length-for-a-vector-in-r – IRTFM Jan 02 '13 at 01:24
1 Answers
4
There is a limit, but it is a limit of vector length, not a limitation of c
:
length(eval(call('c', 1:(2^31-1))))
## [1] 2147483647
length(eval(call('c', 1:(2^31))))
## Error in 1:(2^31) : result would be too long a vector

Matthew Lundberg
- 42,009
- 6
- 90
- 112
-
I think R 3.0 (or whatever version number they end up using) overcomes the 2^31 - 1 index limit – Róisín Grannell Jan 02 '13 at 02:43
-
I'm going to need more memory. `1:(2^31-1)` takes 25% of my RAM, and `1:(2^31-1)+.5` takes 75%. – Matthew Lundberg Jan 02 '13 at 02:50