[R] How to create a high-dimensional matrix

R. Michael Weylandt michael.weylandt at gmail.com
Tue Oct 16 23:18:10 CEST 2012


On Tue, Oct 16, 2012 at 8:46 PM, lrl <liurl1221 at gmail.com> wrote:
> Hi, everyone
>
> I need to create a 429497 x 429497 matrix.
> When I use
> *matrix(0,429497,429497)*
> I got the error information :  Error in matrix(0, 429497, 429497) : too many
> elements specified
>
> Then I use "ff" package, try to store this matrix on disk
> * x<-ff(0,dim=c(429497,429497)*
> And I got the error information :
> Error in if (length < 0 || length > .Machine$integer.max) stop("length must
> be between 1 and .Machine$integer.max") :
>   missing value where TRUE/FALSE needed
> In addition: Warning message:
> In ff(0, dim = c(429497, 429497)) : NAs introduced by coercion
>
> I am using Unix. The free memory is about 33G
>> .Machine$integer.max
> [1] 2147483647
>
> What can I do the create such a high dimension matrix?

You'll note that 429497 ^2 - .Machine$integer.max is still a very
large positive number.

Is your matrix perhaps sparse and you don't actually have to store
quite so many values?

Michael

>
> Many thanks!
>
> Ruiling Liu
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-to-create-a-high-dimensional-matrix-tp4646396.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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