[R] (subscript) logical subscript too long

Maram SAlem marammagdysalem at gmail.com
Thu Oct 1 13:21:38 CEST 2015


Thanks Giorgio, I got it.

 I managed to reach the matrix s whose rows represent  all the possible
combinations. Here is the code:

> n=12
> m=7
> D<-matrix(0,nrow=n-m+1,ncol=m-1)
> for (i in 1:m-1)
+  {
+ D[,i]<-seq(0,n-m,1)
+  }
> ED <- do.call(`expand.grid`,as.data.frame(D))
> ED<-as.matrix(ED)
> lk<-which(rowSums(ED)<=(n-m))
> s<-ED[lk,]

The problem now is that the code works only for relatively small values of
n and m, but when I use, for ex., n=20 and m=9, I got this error

> n=20
> m=9
> D<-matrix(0,nrow=n-m+1,ncol=m-1)
> for (i in 1:m-1)
+  {
+ D[,i]<-seq(0,n-m,1)
+  }
> ED <- do.call(`expand.grid`,as.data.frame(D))

*Error: cannot allocate vector of size 1.6 Gb*

*Any Suggestions please?*

*Thanks Again.*
*Maram*

On 30 September 2015 at 17:41, Giorgio Garziano <
giorgio.garziano at ericsson.com> wrote:

> Be:
>
> log <- (rowSums(ED) <= (n - m))
>
>
> Compare the following two values:
>
>
>
>
>
> length(log)
>
>
>
>
>
> nrow(w)
>
>
>
>
>
> --
>
> GG
>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list