[R] (subscript) logical subscript too long
Maram SAlem
marammagdysalem at gmail.com
Wed Sep 30 17:33:23 CEST 2015
Dear All,
I'm trying to write a function in the values of some numeric vectors
(d1,d2,...,d(m-1)). This function should be applied on some combinations
of the elements of the (m-1) d vectors that satisfy the condition of having
a sum less than or equal to (n-m). I've tried the following code, but got
an error:(subscript) logical subscript too long.
> n=20
> m=6
> 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)
> s<-w[rowSums(ED)<=(n-m),]
Error in w[rowSums(ED) <= (n - m), ] :
(subscript) logical subscript too long
Bearing in mind that the true values of n and m might be way larger than 20
and 6, consecutively.
Any Suggestions please?
Thanks.
Maram
[[alternative HTML version deleted]]
More information about the R-help
mailing list