2014-12-29 29 views
-2

我从来没有使用过R和因此需要在看似琐碎问题的帮助:如何将Excel读入R并执行hurst(x)?

我有一个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" 

有什么不对?

+2

'install.packages( “pracma”);库( “pracma”)'; http://stackoverflow.com/questions/7049272/importing-xlsx-file-into-r; '赫斯特(imported_data [[1]])';然后编辑你的问题,让我们知道你仍然坚持的东西(它可能会在此期间被关闭......) –

+0

谷歌搜索应该已经出现[XLConnect](http://cran.r-project .org/web/packages/XLConnect/vignettes/XLConnect.pdf)以及用于导入Excel文件的其他几个软件包。 – nrussell

回答

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 
+0

它给出了“矩阵(x,n,m)中的错误:无效'nrow'值(太大或NA)”?然而,“> sum(theData [[1]]) [1] -59.86539”作品 – emcor

+0

我认为我们需要一个[可重现的例子](http://tinyurl.com/reproducible-000)请... –

+0

我上传了Excel文件[here](http://www.filedropper.com/data_4)。我想用这个数据调用“hurstexp(x)”... – emcor