[R] Requesting for help on the problem of "subscript out of bounds"

Jim Lemon drj|m|emon @end|ng |rom gm@||@com
Sat Oct 6 10:51:56 CEST 2018


Hi Subhamitra,
Where I think the error arises is in the line:

 N<-nrow(mat)

Since we don't know what "mat" is, we don't know what nrow(mat) will
return. If "mat" is not a matrix or data frame, it is likely to be
NULL. Try this:

print(N)

after defining it and see what it is.

Jim

On Sat, Oct 6, 2018 at 5:51 PM Subhamitra Patra
<subhamitra.patra using gmail.com> wrote:
>
> Hello friends,
>
> I am very new in this R world. But, still doing some programming by
> learning. While running one code, I found the problem of "subscript out of
> bounds". Please suggest me how to overcome this problem? For your
> reference, I am uploading my code here.
>
> The function
>
> approx_entropy(ts, edim =2, r = 0.2*sd(ts), elag = 1)
>
> library(pracma)
>
> N<-nrow(mat)
> r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
>      r[i]<-approx_entropy(mat[i,], edim = 2, r = 0.2*sd(mat[i,]), elag = 1)}
>
> After running this code, I am getting the error of
>
> *"subscript out of bounds"*
>
> Please help me for which I shall be always grateful to you.
>
> Thanks in advance.
>
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using 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.




More information about the R-help mailing list