-2

I never used R before and so need help on a seemingly trivial issue:

I have an excel file "data.xlsx", available here, and want to run the function hurst(x) on it: http://www.inside-r.org/packages/cran/pracma/docs/hurst

I did:

theData <- readWorksheetFromFile("C:\\Users\\David\\Desktop\\R\\data.xlsx",sheet=1)

Which works fine. Then I try

library(pracma)
hurst(theData)

Which returns

   Error: could not find function "hurst"

What is wrong?

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
emcor
  • 284
  • 4
  • 15
  • 2
    `install.packages("pracma"); library("pracma")`; http://stackoverflow.com/questions/7049272/importing-xlsx-file-into-r ; `hurst(imported_data[[1]])`; and then edit your question to let us know what you're still stuck on (it may well be closed in the meanwhile ...) – Ben Bolker Dec 29 '14 at 15:48
  • A Google search should have turned up [XLConnect](http://cran.r-project.org/web/packages/XLConnect/vignettes/XLConnect.pdf), among several other packages for importing Excel files. – nrussell Dec 29 '14 at 15:51

1 Answers1

3

It looks like the link you gave points to an old version of the package; the hurst function no longer exists in the package. The current documentation is here; try

library("gdata")  ## my favorite XLS-reader
x <- read.xls("hurstdata.xlsx",header=FALSE)
hurstexp(x[[1]])
## Simple R/S Hurst estimation:         0.5488892 
## Corrected R over S Hurst exponent:   0.6172157 
## Empirical Hurst exponent:            0.6796684 
## Corrected empirical Hurst exponent:  0.6438013 
## Theoretical Hurst exponent:          0.5316731 

Abridged session information:

R Under development (unstable) (2014-09-17 r66626)
Platform: i686-pc-linux-gnu (32-bit)

other attached packages:
[1] pracma_1.7.9 gdata_2.13.3
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • It gives "Error in matrix(x, n, m) : invalid 'nrow' value (too large or NA)"? However, "> sum(theData[[1]]) [1] -59.86539" works – emcor Dec 29 '14 at 16:59
  • I think we need a [reproducible example](http://tinyurl.com/reproducible-000) please ... – Ben Bolker Dec 29 '14 at 17:00
  • I uploaded the Excel file [here](http://www.filedropper.com/data_4). I want to call "hurstexp(x)" with this data... – emcor Dec 29 '14 at 17:04