Requesting for help on the problem of "subscript out of bounds"

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Jim Lemon-4
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
<[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
Hello Sir,

I tried by defining mat, but still facing the same problem.

Hence, mat represents the time series. This time, I defined it as ts and
tried, but still having the same problem.

In particular, the problem is coming in the following line
*for (i in 1:N){*
*+     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag =
1) *

where i is unable to synchronize with the no. of rows i.e. rows and thus I
am getting the error of

*Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :   subscript out
of bounds*

For your reference, I am providing my full code with an explanation as
follows.

The function

approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)

from the package,pracma I am calculating the approximate entropy of time
series.ts

I have a matrix of time series (one series per row i.e. 51 rows and 1
column)  and I would estimate the approximate entropy for each of the rows,
storing the results in a vector. So, I have written a code

library(pracma)

N<-nrow(ts)
r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)}

* After calculating for 1 series, I need to calculate the same things for
the multiple series by changing the dimension of the ncol.*

Please help me in this regard.

Thanks in advance.

On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]> wrote:

> 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
> <[hidden email]> 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]]
> >
> > ______________________________________________
> > [hidden email] 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.
>


--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Jim Lemon-4
What I would do next is to insert a line to see where it goes wrong:

for (i in 1:N){
     cat("i =",i,"\n")
     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)
}

The last i that is printed (which may be the first) will reveal what
caused the error I hope.

Jim

On Sat, Oct 6, 2018 at 7:12 PM Subhamitra Patra
<[hidden email]> wrote:

>
> Hello Sir,
>
> I tried by defining mat, but still facing the same problem.
>
> Hence, mat represents the time series. This time, I defined it as ts and tried, but still having the same problem.
>
> In particular, the problem is coming in the following line
> for (i in 1:N){
> +     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)
>
> where i is unable to synchronize with the no. of rows i.e. rows and thus I am getting the error of
>
> Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :
>   subscript out of bounds
>
> For your reference, I am providing my full code with an explanation as follows.
>
> The function
>
> approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)
>
> from the package,pracma I am calculating the approximate entropy of time series.ts
>
> I have a matrix of time series (one series per row i.e. 51 rows and 1 column)  and I would estimate the approximate entropy for each of the rows, storing the results in a vector. So, I have written a code
>
> library(pracma)
>
> N<-nrow(ts)
> r<-matrix(0, nrow = N, ncol = 1)
> for (i in 1:N){
>      r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)
> }
>
>  After calculating for 1 series, I need to calculate the same things for the multiple series by changing the dimension of the ncol.
>
> Please help me in this regard.
>
> Thanks in advance.
>
> On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]> wrote:
>>
>> 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
>> <[hidden email]> 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]]
>> >
>> > ______________________________________________
>> > [hidden email] 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.
>
>
>
> --
> Best Regards,
> Subhamitra Patra
> Phd. Research Scholar
> Department of Humanities and Social Sciences
> Indian Institute of Technology, Kharagpur
> INDIA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Rui Barradas
In reply to this post by Subhamitra Patra
Hello,
Instead of nrow try all uppercase:
N <- NROW (ts)

Hope this helps,
Rui Barradas 



Enviado a partir do meu smartphone Samsung Galaxy.-------- Mensagem original --------De: Subhamitra Patra <[hidden email]> Data: 06/10/2018  10:14  (GMT+00:00) Para: [hidden email] Cc: [hidden email] Assunto: Re: [R]
  Requesting for help on the problem of "subscript out of bounds"
Hello Sir,

I tried by defining mat, but still facing the same problem.

Hence, mat represents the time series. This time, I defined it as ts and
tried, but still having the same problem.

In particular, the problem is coming in the following line
*for (i in 1:N){*
*+     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag =
1) *

where i is unable to synchronize with the no. of rows i.e. rows and thus I
am getting the error of

*Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :   subscript out
of bounds*

For your reference, I am providing my full code with an explanation as
follows.

The function

approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)

from the package,pracma I am calculating the approximate entropy of time
series.ts

I have a matrix of time series (one series per row i.e. 51 rows and 1
column)  and I would estimate the approximate entropy for each of the rows,
storing the results in a vector. So, I have written a code

library(pracma)

N<-nrow(ts)
r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)}

* After calculating for 1 series, I need to calculate the same things for
the multiple series by changing the dimension of the ncol.*

Please help me in this regard.

Thanks in advance.

On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]> wrote:

> 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
> <[hidden email]> 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]]
> >
> > ______________________________________________
> > [hidden email] 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.
>


--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
I am extremely sorry to say that both the suggestions did not work.

I did not understand the suggestion of Prof. Lemon. So, Sir, Can you please
clarify me your suggestion?

 I tried the suggestion of Ruipbarradas. It does not work.

Please help me out for which I shall be always grateful to you.

Thanks in advance.

On Sat, Oct 6, 2018 at 2:48 PM ruipbarradas <[hidden email]> wrote:

> Hello,
>
> Instead of nrow try all uppercase:
>
> N <- NROW (ts)
>
>
> Hope this helps,
>
> Rui Barradas
>
>
>
>
> Enviado a partir do meu smartphone Samsung Galaxy.
> -------- Mensagem original --------
> De: Subhamitra Patra <[hidden email]>
> Data: 06/10/2018 10:14 (GMT+00:00)
> Para: [hidden email]
> Cc: [hidden email]
> Assunto: Re: [R] Requesting for help on the problem of "subscript out of
> bounds"
>
> Hello Sir,
>
> I tried by defining mat, but still facing the same problem.
>
> Hence, mat represents the time series. This time, I defined it as ts and
> tried, but still having the same problem.
>
> In particular, the problem is coming in the following line
> *for (i in 1:N){*
> *+     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag =
> 1) *
>
> where i is unable to synchronize with the no. of rows i.e. rows and thus I
> am getting the error of
>
> *Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :   subscript out
> of bounds*
>
> For your reference, I am providing my full code with an explanation as
> follows.
>
> The function
>
> approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)
>
> from the package,pracma I am calculating the approximate entropy of time
> series.ts
>
> I have a matrix of time series (one series per row i.e. 51 rows and 1
> column)  and I would estimate the approximate entropy for each of the rows,
> storing the results in a vector. So, I have written a code
>
> library(pracma)
>
> N<-nrow(ts)
> r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
>      r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)}
>
> * After calculating for 1 series, I need to calculate the same things for
> the multiple series by changing the dimension of the ncol.*
>
> Please help me in this regard.
>
> Thanks in advance.
>
> On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]> wrote:
>
> > 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
> > <[hidden email]> 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]]
> > >
> > > ______________________________________________
> > > [hidden email] 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.
> >
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
>


--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Jim Lemon-4
The idea of using:

cat("i =",i,"\n")

is to display the value of i each time the loop executes. Displaying i
_before_ the error occurs tells us what value of i is causing the
problem. Because the error is occurring when you try to index ts,
perhaps adding:

cat(dim(ts),"\n")
for(i in 1:N) {
...

_before_ the loop starts will tell you what the dimensions of ts are.
It way well be a list that you have to use a different syntax for
indexing. An even more complete description of ts can be had like
this:

str(ts)

Unfortunately I am about to log out and get some sleep so I will not
be able to continue answering until some time tomorrow.

Jim
On Sat, Oct 6, 2018 at 7:32 PM Subhamitra Patra
<[hidden email]> wrote:

>
> I am extremely sorry to say that both the suggestions did not work.
>
> I did not understand the suggestion of Prof. Lemon. So, Sir, Can you please clarify me your suggestion?
>
>  I tried the suggestion of Ruipbarradas. It does not work.
>
>
> Please help me out for which I shall be always grateful to you.
>
> Thanks in advance.
>
> On Sat, Oct 6, 2018 at 2:48 PM ruipbarradas <[hidden email]> wrote:
>>
>> Hello,
>>
>> Instead of nrow try all uppercase:
>>
>> N <- NROW (ts)
>>
>>
>> Hope this helps,
>>
>> Rui Barradas
>>
>>
>>
>>
>> Enviado a partir do meu smartphone Samsung Galaxy.
>> -------- Mensagem original --------
>> De: Subhamitra Patra <[hidden email]>
>> Data: 06/10/2018 10:14 (GMT+00:00)
>> Para: [hidden email]
>> Cc: [hidden email]
>> Assunto: Re: [R] Requesting for help on the problem of "subscript out of bounds"
>>
>> Hello Sir,
>>
>> I tried by defining mat, but still facing the same problem.
>>
>> Hence, mat represents the time series. This time, I defined it as ts and
>> tried, but still having the same problem.
>>
>> In particular, the problem is coming in the following line
>> *for (i in 1:N){*
>> *+     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag =
>> 1) *
>>
>> where i is unable to synchronize with the no. of rows i.e. rows and thus I
>> am getting the error of
>>
>> *Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :   subscript out
>> of bounds*
>>
>> For your reference, I am providing my full code with an explanation as
>> follows.
>>
>> The function
>>
>> approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)
>>
>> from the package,pracma I am calculating the approximate entropy of time
>> series.ts
>>
>> I have a matrix of time series (one series per row i.e. 51 rows and 1
>> column)  and I would estimate the approximate entropy for each of the rows,
>> storing the results in a vector. So, I have written a code
>>
>> library(pracma)
>>
>> N<-nrow(ts)
>> r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
>>      r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)}
>>
>> * After calculating for 1 series, I need to calculate the same things for
>> the multiple series by changing the dimension of the ncol.*
>>
>> Please help me in this regard.
>>
>> Thanks in advance.
>>
>> On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]> wrote:
>>
>> > 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
>> > <[hidden email]> 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]]
>> > >
>> > > ______________________________________________
>> > > [hidden email] 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.
>> >
>>
>>
>> --
>> *Best Regards,*
>> *Subhamitra Patra*
>> *Phd. Research Scholar*
>> *Department of Humanities and Social Sciences*
>> *Indian Institute of Technology, Kharagpur*
>> *INDIA*
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] 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.
>
>
>
> --
> Best Regards,
> Subhamitra Patra
> Phd. Research Scholar
> Department of Humanities and Social Sciences
> Indian Institute of Technology, Kharagpur
> INDIA

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Rui Barradas
In reply to this post by Subhamitra Patra
Hello,

I suggested NROW (all uppercase) because it works even if its argument,
in your case ts, has only one dimension, nrow needs 2-dim objects.

I have now noticed that you are indexing ts as if it has two dimensions,
and that r is created with function matrix() but then you index it with
just one dimension.


r[i] <- approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)


Shouldn't it be ts[i] or r[i, ] ?

Hope this helps,

Rui Barradas

Às 10:34 de 06/10/2018, Subhamitra Patra escreveu:

> I am extremely sorry to say that both the suggestions did not work.
>
> I did not understand the suggestion of Prof. Lemon. So, Sir, Can you
> please clarify me your suggestion?
>
>
>         I tried the suggestion of Ruipbarradas. It does not work.
>
>
> Please help me out for which I shall be always grateful to you.
>
> Thanks in advance.
>
> On Sat, Oct 6, 2018 at 2:48 PM ruipbarradas <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>
>     Instead of nrow try all uppercase:
>
>     N <- NROW (ts)
>
>
>     Hope this helps,
>
>     Rui Barradas
>
>
>
>
>     Enviado a partir do meu smartphone Samsung Galaxy.
>     -------- Mensagem original --------
>     De: Subhamitra Patra <[hidden email]
>     <mailto:[hidden email]>>
>     Data: 06/10/2018 10:14 (GMT+00:00)
>     Para: [hidden email] <mailto:[hidden email]>
>     Cc: [hidden email] <mailto:[hidden email]>
>     Assunto: Re: [R] Requesting for help on the problem of "subscript
>     out of bounds"
>
>     Hello Sir,
>
>     I tried by defining mat, but still facing the same problem.
>
>     Hence, mat represents the time series. This time, I defined it as ts and
>     tried, but still having the same problem.
>
>     In particular, the problem is coming in the following line
>     *for (i in 1:N){*
>     *+     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag =
>     1) *
>
>     where i is unable to synchronize with the no. of rows i.e. rows and
>     thus I
>     am getting the error of
>
>     *Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :  
>     subscript out
>     of bounds*
>
>     For your reference, I am providing my full code with an explanation as
>     follows.
>
>     The function
>
>     approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)
>
>     from the package,pracma I am calculating the approximate entropy of time
>     series.ts
>
>     I have a matrix of time series (one series per row i.e. 51 rows and 1
>     column)  and I would estimate the approximate entropy for each of
>     the rows,
>     storing the results in a vector. So, I have written a code
>
>     library(pracma)
>
>     N<-nrow(ts)
>     r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
>           r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]),
>     elag = 1)}
>
>     * After calculating for 1 series, I need to calculate the same
>     things for
>     the multiple series by changing the dimension of the ncol.*
>
>     Please help me in this regard.
>
>     Thanks in advance.
>
>     On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]
>     <mailto:[hidden email]>> wrote:
>
>      > 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
>      > <[hidden email] <mailto:[hidden email]>>
>     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]]
>      > >
>      > > ______________________________________________
>      > > [hidden email] <mailto:[hidden email]> 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.
>      >
>
>
>     --
>     *Best Regards,*
>     *Subhamitra Patra*
>     *Phd. Research Scholar*
>     *Department of Humanities and Social Sciences*
>     *Indian Institute of Technology, Kharagpur*
>     *INDIA*
>
>     [[alternative HTML version deleted]]
>
>     ______________________________________________
>     [hidden email] <mailto:[hidden email]> 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.
>
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
Yes, I tried as per your suggestion, but not getting any results. I think,
there is some dimension mismatch in the data matrix and result matrix.

I have to compute the particular model yearly for each series.

Please help.

Thanks in advance.


On Sat, Oct 6, 2018 at 4:58 PM Rui Barradas <[hidden email]> wrote:

> Hello,
>
> I suggested NROW (all uppercase) because it works even if its argument,
> in your case ts, has only one dimension, nrow needs 2-dim objects.
>
> I have now noticed that you are indexing ts as if it has two dimensions,
> and that r is created with function matrix() but then you index it with
> just one dimension.
>
>
> r[i] <- approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)
>
>
> Shouldn't it be ts[i] or r[i, ] ?
>
> Hope this helps,
>
> Rui Barradas
>
> Às 10:34 de 06/10/2018, Subhamitra Patra escreveu:
> > I am extremely sorry to say that both the suggestions did not work.
> >
> > I did not understand the suggestion of Prof. Lemon. So, Sir, Can you
> > please clarify me your suggestion?
> >
> >
> >         I tried the suggestion of Ruipbarradas. It does not work.
> >
> >
> > Please help me out for which I shall be always grateful to you.
> >
> > Thanks in advance.
> >
> > On Sat, Oct 6, 2018 at 2:48 PM ruipbarradas <[hidden email]
> > <mailto:[hidden email]>> wrote:
> >
> >     Hello,
> >
> >     Instead of nrow try all uppercase:
> >
> >     N <- NROW (ts)
> >
> >
> >     Hope this helps,
> >
> >     Rui Barradas
> >
> >
> >
> >
> >     Enviado a partir do meu smartphone Samsung Galaxy.
> >     -------- Mensagem original --------
> >     De: Subhamitra Patra <[hidden email]
> >     <mailto:[hidden email]>>
> >     Data: 06/10/2018 10:14 (GMT+00:00)
> >     Para: [hidden email] <mailto:[hidden email]>
> >     Cc: [hidden email] <mailto:[hidden email]>
> >     Assunto: Re: [R] Requesting for help on the problem of "subscript
> >     out of bounds"
> >
> >     Hello Sir,
> >
> >     I tried by defining mat, but still facing the same problem.
> >
> >     Hence, mat represents the time series. This time, I defined it as ts
> and
> >     tried, but still having the same problem.
> >
> >     In particular, the problem is coming in the following line
> >     *for (i in 1:N){*
> >     *+     r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]),
> elag =
> >     1) *
> >
> >     where i is unable to synchronize with the no. of rows i.e. rows and
> >     thus I
> >     am getting the error of
> >
> >     *Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :
> >     subscript out
> >     of bounds*
> >
> >     For your reference, I am providing my full code with an explanation
> as
> >     follows.
> >
> >     The function
> >
> >     approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)
> >
> >     from the package,pracma I am calculating the approximate entropy of
> time
> >     series.ts
> >
> >     I have a matrix of time series (one series per row i.e. 51 rows and 1
> >     column)  and I would estimate the approximate entropy for each of
> >     the rows,
> >     storing the results in a vector. So, I have written a code
> >
> >     library(pracma)
> >
> >     N<-nrow(ts)
> >     r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
> >           r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]),
> >     elag = 1)}
> >
> >     * After calculating for 1 series, I need to calculate the same
> >     things for
> >     the multiple series by changing the dimension of the ncol.*
> >
> >     Please help me in this regard.
> >
> >     Thanks in advance.
> >
> >     On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon <[hidden email]
> >     <mailto:[hidden email]>> wrote:
> >
> >      > 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
> >      > <[hidden email] <mailto:[hidden email]>>
> >     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]]
> >      > >
> >      > > ______________________________________________
> >      > > [hidden email] <mailto:[hidden email]> 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.
> >      >
> >
> >
> >     --
> >     *Best Regards,*
> >     *Subhamitra Patra*
> >     *Phd. Research Scholar*
> >     *Department of Humanities and Social Sciences*
> >     *Indian Institute of Technology, Kharagpur*
> >     *INDIA*
> >
> >     [[alternative HTML version deleted]]
> >
> >     ______________________________________________
> >     [hidden email] <mailto:[hidden email]> 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.
> >
> >
> >
> > --
> > *Best Regards,*
> > *Subhamitra Patra*
> > *Phd. Research Scholar*
> > *Department of Humanities and Social Sciences*
> > *Indian Institute of Technology, Kharagpur*
> > *INDIA*
>


--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Rui Barradas
Hello,

Can you post the output of

dput(head(ts, 20))    # paste the output of this in a mail
dim(ts)               # and this


Rui Barradas

Às 15:45 de 06/10/2018, Subhamitra Patra escreveu:

> Yes, I tried as per your suggestion, but not getting any results. I
> think, there is some dimension mismatch in the data matrix and result
> matrix.
>
> I have to compute the particular model yearly for each series.
>
> Please help.
>
> Thanks in advance.
>
>
> On Sat, Oct 6, 2018 at 4:58 PM Rui Barradas <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hello,
>
>     I suggested NROW (all uppercase) because it works even if its argument,
>     in your case ts, has only one dimension, nrow needs 2-dim objects.
>
>     I have now noticed that you are indexing ts as if it has two
>     dimensions,
>     and that r is created with function matrix() but then you index it with
>     just one dimension.
>
>
>     r[i] <- approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]), elag = 1)
>
>
>     Shouldn't it be ts[i] or r[i, ] ?
>
>     Hope this helps,
>
>     Rui Barradas
>
>     Às 10:34 de 06/10/2018, Subhamitra Patra escreveu:
>      > I am extremely sorry to say that both the suggestions did not work.
>      >
>      > I did not understand the suggestion of Prof. Lemon. So, Sir, Can you
>      > please clarify me your suggestion?
>      >
>      >
>      >         I tried the suggestion of Ruipbarradas. It does not work.
>      >
>      >
>      > Please help me out for which I shall be always grateful to you.
>      >
>      > Thanks in advance.
>      >
>      > On Sat, Oct 6, 2018 at 2:48 PM ruipbarradas <[hidden email]
>     <mailto:[hidden email]>
>      > <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>      >
>      >     Hello,
>      >
>      >     Instead of nrow try all uppercase:
>      >
>      >     N <- NROW (ts)
>      >
>      >
>      >     Hope this helps,
>      >
>      >     Rui Barradas
>      >
>      >
>      >
>      >
>      >     Enviado a partir do meu smartphone Samsung Galaxy.
>      >     -------- Mensagem original --------
>      >     De: Subhamitra Patra <[hidden email]
>     <mailto:[hidden email]>
>      >     <mailto:[hidden email]
>     <mailto:[hidden email]>>>
>      >     Data: 06/10/2018 10:14 (GMT+00:00)
>      >     Para: [hidden email] <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>>
>      >     Cc: [hidden email] <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>>
>      >     Assunto: Re: [R] Requesting for help on the problem of "subscript
>      >     out of bounds"
>      >
>      >     Hello Sir,
>      >
>      >     I tried by defining mat, but still facing the same problem.
>      >
>      >     Hence, mat represents the time series. This time, I defined
>     it as ts and
>      >     tried, but still having the same problem.
>      >
>      >     In particular, the problem is coming in the following line
>      >     *for (i in 1:N){*
>      >     *+     r[i]<-approx_entropy(ts[i,], edim = 2, r =
>     0.2*sd(ts[i,]), elag =
>      >     1) *
>      >
>      >     where i is unable to synchronize with the no. of rows i.e.
>     rows and
>      >     thus I
>      >     am getting the error of
>      >
>      >     *Error in `[<-`(`*tmp*`, i, , value = ts[i:(N - m + i)]) :
>      >     subscript out
>      >     of bounds*
>      >
>      >     For your reference, I am providing my full code with an
>     explanation as
>      >     follows.
>      >
>      >     The function
>      >
>      >     approx_entropy(ts, edim = 2, r = 0.2*sd(ts), elag = 1)
>      >
>      >     from the package,pracma I am calculating the approximate
>     entropy of time
>      >     series.ts
>      >
>      >     I have a matrix of time series (one series per row i.e. 51
>     rows and 1
>      >     column)  and I would estimate the approximate entropy for each of
>      >     the rows,
>      >     storing the results in a vector. So, I have written a code
>      >
>      >     library(pracma)
>      >
>      >     N<-nrow(ts)
>      >     r<-matrix(0, nrow = N, ncol = 1)for (i in 1:N){
>      >           r[i]<-approx_entropy(ts[i,], edim = 2, r = 0.2*sd(ts[i,]),
>      >     elag = 1)}
>      >
>      >     * After calculating for 1 series, I need to calculate the same
>      >     things for
>      >     the multiple series by changing the dimension of the ncol.*
>      >
>      >     Please help me in this regard.
>      >
>      >     Thanks in advance.
>      >
>      >     On Sat, Oct 6, 2018 at 2:22 PM Jim Lemon
>     <[hidden email] <mailto:[hidden email]>
>      >     <mailto:[hidden email] <mailto:[hidden email]>>>
>     wrote:
>      >
>      >      > 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
>      >      > <[hidden email]
>     <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>>>
>      >     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]]
>      >      > >
>      >      > > ______________________________________________
>      >      > > [hidden email] <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>> 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.
>      >      >
>      >
>      >
>      >     --
>      >     *Best Regards,*
>      >     *Subhamitra Patra*
>      >     *Phd. Research Scholar*
>      >     *Department of Humanities and Social Sciences*
>      >     *Indian Institute of Technology, Kharagpur*
>      >     *INDIA*
>      >
>      >     [[alternative HTML version deleted]]
>      >
>      >     ______________________________________________
>      > [hidden email] <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>> 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.
>      >
>      >
>      >
>      > --
>      > *Best Regards,*
>      > *Subhamitra Patra*
>      > *Phd. Research Scholar*
>      > *Department of Humanities and Social Sciences*
>      > *Indian Institute of Technology, Kharagpur*
>      > *INDIA*
>
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
Thanks a lot, Sir. I'll check them out.

But, I have 1 more query that in which package   "b" and "l" functions are
available?

Can you please educate me about the usage of "b" and "I" in my code.

For your reference,

I am writing my code here again.

N<-ncol(ts)
> r<-matrix(0, ncol = N, nrow = 1)
> for (i in 1:N){
       r[i]<-approx_entropy(ts[,i], edim = 2, r = 0.2*sd(ts[,i]), elag = 1)
}
plot (r)

Here how to add "b" and "l" function?

Please help me.

Thanks in advance.

On Sun, Oct 7, 2018 at 3:19 PM Jim Lemon <[hidden email]> wrote:

> plot(r) will give you a set of points with the values of r on the y
> axis and 1:N on the x axis. If you want to add more series, look at
> "points" or "lines". Also look at the options "b" and "l" for plot if
> you want points and lines or just lines respectively.
>
> Jim
>
> On Sun, Oct 7, 2018 at 6:03 PM Subhamitra Patra
> <[hidden email]> wrote:
> >
> > Hello friends,
> >
> > Finally, I became able to compute APEn values for each series.
> >
> > Actually, there was a small mistake in the code for the arguments of row
> and columns. Now, after rectifying my mistakes as well as by taking the
> suggestions from Rui Barradas and Jim, It became possible. Therefore, I
> would like to say thanks to both of you.
> >
> > One small help (if possible) that I want to plot that particular APEn
> values for each series.
> > Only, I will write the code "plot (r)" or any other code is there?
> >
> > Please help.
> >
> > 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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
Dear Friends,

Further, I want to compute the APEn values for the multiple files in a
folder. In particular, along with the loop for the columns in one data file
(through the code that I mentioned above), I have to write a loop for the
multiple files (having same dimensions) in a folder.

But, I am not getting a proper idea for writing the double loop (i.e. one
for the multiple columns of one excel sheet and other for the multiple
excel sheets of a folder).

Please help me in this regard.

Thanks in advance.

On Sun, Oct 7, 2018 at 3:33 PM Subhamitra Patra <[hidden email]>
wrote:

> Thanks a lot, Sir. I'll check them out.
>
> But, I have 1 more query that in which package   "b" and "l" functions
> are available?
>
> Can you please educate me about the usage of "b" and "I" in my code.
>
> For your reference,
>
> I am writing my code here again.
>
> N<-ncol(ts)
> > r<-matrix(0, ncol = N, nrow = 1)
> > for (i in 1:N){
>        r[i]<-approx_entropy(ts[,i], edim = 2, r = 0.2*sd(ts[,i]), elag = 1)
> }
> plot (r)
>
> Here how to add "b" and "l" function?
>
> Please help me.
>
> Thanks in advance.
>
> On Sun, Oct 7, 2018 at 3:19 PM Jim Lemon <[hidden email]> wrote:
>
>> plot(r) will give you a set of points with the values of r on the y
>> axis and 1:N on the x axis. If you want to add more series, look at
>> "points" or "lines". Also look at the options "b" and "l" for plot if
>> you want points and lines or just lines respectively.
>>
>> Jim
>>
>> On Sun, Oct 7, 2018 at 6:03 PM Subhamitra Patra
>> <[hidden email]> wrote:
>> >
>> > Hello friends,
>> >
>> > Finally, I became able to compute APEn values for each series.
>> >
>> > Actually, there was a small mistake in the code for the arguments of
>> row and columns. Now, after rectifying my mistakes as well as by taking the
>> suggestions from Rui Barradas and Jim, It became possible. Therefore, I
>> would like to say thanks to both of you.
>> >
>> > One small help (if possible) that I want to plot that particular APEn
>> values for each series.
>> > Only, I will write the code "plot (r)" or any other code is there?
>> >
>> > Please help.
>> >
>> > Thanks in advance.
>>
>
>
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> *INDIA*
>


--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Michael Dewey-3
In reply to this post by Subhamitra Patra
If you look at the documentation for plot() you will see a type
parameter which can take a number of values including plot = "l" to get
lines, and so on.

On 07/10/2018 11:03, Subhamitra Patra wrote:

> Thanks a lot, Sir. I'll check them out.
>
> But, I have 1 more query that in which package   "b" and "l" functions are
> available?
>
> Can you please educate me about the usage of "b" and "I" in my code.
>
> For your reference,
>
> I am writing my code here again.
>
> N<-ncol(ts)
>> r<-matrix(0, ncol = N, nrow = 1)
>> for (i in 1:N){
>         r[i]<-approx_entropy(ts[,i], edim = 2, r = 0.2*sd(ts[,i]), elag = 1)
> }
> plot (r)
>
> Here how to add "b" and "l" function?
>
> Please help me.
>
> Thanks in advance.
>
> On Sun, Oct 7, 2018 at 3:19 PM Jim Lemon <[hidden email]> wrote:
>
>> plot(r) will give you a set of points with the values of r on the y
>> axis and 1:N on the x axis. If you want to add more series, look at
>> "points" or "lines". Also look at the options "b" and "l" for plot if
>> you want points and lines or just lines respectively.
>>
>> Jim
>>
>> On Sun, Oct 7, 2018 at 6:03 PM Subhamitra Patra
>> <[hidden email]> wrote:
>>>
>>> Hello friends,
>>>
>>> Finally, I became able to compute APEn values for each series.
>>>
>>> Actually, there was a small mistake in the code for the arguments of row
>> and columns. Now, after rectifying my mistakes as well as by taking the
>> suggestions from Rui Barradas and Jim, It became possible. Therefore, I
>> would like to say thanks to both of you.
>>>
>>> One small help (if possible) that I want to plot that particular APEn
>> values for each series.
>>> Only, I will write the code "plot (r)" or any other code is there?
>>>
>>> Please help.
>>>
>>> Thanks in advance.
>>
>
>

--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Requesting for help on the problem of "subscript out of bounds"

Subhamitra Patra
Thanks a lot.

On Sun, Oct 7, 2018 at 6:16 PM Michael Dewey <[hidden email]>
wrote:

> If you look at the documentation for plot() you will see a type
> parameter which can take a number of values including plot = "l" to get
> lines, and so on.
>
> On 07/10/2018 11:03, Subhamitra Patra wrote:
> > Thanks a lot, Sir. I'll check them out.
> >
> > But, I have 1 more query that in which package   "b" and "l" functions
> are
> > available?
> >
> > Can you please educate me about the usage of "b" and "I" in my code.
> >
> > For your reference,
> >
> > I am writing my code here again.
> >
> > N<-ncol(ts)
> >> r<-matrix(0, ncol = N, nrow = 1)
> >> for (i in 1:N){
> >         r[i]<-approx_entropy(ts[,i], edim = 2, r = 0.2*sd(ts[,i]), elag
> = 1)
> > }
> > plot (r)
> >
> > Here how to add "b" and "l" function?
> >
> > Please help me.
> >
> > Thanks in advance.
> >
> > On Sun, Oct 7, 2018 at 3:19 PM Jim Lemon <[hidden email]> wrote:
> >
> >> plot(r) will give you a set of points with the values of r on the y
> >> axis and 1:N on the x axis. If you want to add more series, look at
> >> "points" or "lines". Also look at the options "b" and "l" for plot if
> >> you want points and lines or just lines respectively.
> >>
> >> Jim
> >>
> >> On Sun, Oct 7, 2018 at 6:03 PM Subhamitra Patra
> >> <[hidden email]> wrote:
> >>>
> >>> Hello friends,
> >>>
> >>> Finally, I became able to compute APEn values for each series.
> >>>
> >>> Actually, there was a small mistake in the code for the arguments of
> row
> >> and columns. Now, after rectifying my mistakes as well as by taking the
> >> suggestions from Rui Barradas and Jim, It became possible. Therefore, I
> >> would like to say thanks to both of you.
> >>>
> >>> One small help (if possible) that I want to plot that particular APEn
> >> values for each series.
> >>> Only, I will write the code "plot (r)" or any other code is there?
> >>>
> >>> Please help.
> >>>
> >>> Thanks in advance.
> >>
> >
> >
>
> --
> Michael
> http://www.dewey.myzen.co.uk/home.html
>


--
*Best Regards,*
*Subhamitra Patra*
*Phd. Research Scholar*
*Department of Humanities and Social Sciences*
*Indian Institute of Technology, Kharagpur*
*INDIA*

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.