如何将Excel读入R并执行hurst(x)?

时间:2014-12-29 15:19:38

标签: r

我之前从未使用过R,所以在一个看似微不足道的问题上需要帮助:

我有一个excel文件" data.xlsx",可用here,并希望在其上运行hurst(x)函数:http://www.inside-r.org/packages/cran/pracma/docs/hurst

我做了:

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

哪个工作正常。然后我试试

library(pracma)
hurst(theData)

返回

   Error: could not find function "hurst"

有什么问题?

1 个答案:

答案 0 :(得分:3)

看起来你给的链接指向旧版本的包;包中不再存在hurst函数。目前的文件是here;试试

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 

简短的会话信息:

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