Error while using aroon function in R

177 views Asked by At

I'm having a dataset like this:

            d        price  volume
1  2014-10-30  0.00000e+00 2534450
2  2014-10-30  0.00000e+00    2250
3  2014-10-30 -6.11322e-06    2800
4  2014-10-30 -4.27925e-05    1550
5  2014-10-30  9.78115e-05    1300
6  2014-10-30  1.10038e-04    2950
7  2014-10-30  6.11322e-05    1800

I'm applying aroon function from TTR package on this. If I'm using it in middle of my big function

pager <-data.frame()
pager <- aroon( data3[,c("price")], n=5 )
View(pager)

It throws an error

Error in -low : invalid argument to unary operator

If I use it directly on the console it gives correct results Can anyone tell me where the problem is?

I'm using TTR, quantmod, xts and zoo packages.

Browse[1]> str(data3)
 chr [1:29, 1:3] "2014-10-30" "2014-10-30" "2014-10-30" "2014-10-30" ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:29] "2" "3" "4" "5" ...
  ..$ : chr [1:3] "d" "price" "volume"
Browse[1]> summary(data3)
          d               price        volume  
 2014-10-30:29    3.11774e-04: 3      1000: 3  
                  2.32302e-04: 2       900: 2  
                  3.17887e-04: 2       200: 1  
                  6.11322e-05: 2       400: 1  
                 -4.27925e-05: 1       500: 1  
                 -6.11322e-06: 1       600: 1  
                 (Other)     :18   (Other):20  
1

There are 1 answers

0
Joshua Ulrich On

The error is because the first argument you pass to the aroon function is not one of the following types: logical, integer, double, complex. You did not provide enough information for me to be more specific.

If I had to guess, I would say your data are either factor or character when that error is thrown.