0
我試圖打開一個excel文件並做迴歸分析,但出現了一些錯誤。所以我在這裏writen的命令,如果有人會這麼好來幫我我沒有用過這個節目不僅僅是幾次..R項目文件打開問題
> library(RODBC)
> library(mlogit)
Loading required package: Formula
Loading required package: statmod
Loading required package: lmtest
Loading required package: zoo
Attaching package: 'zoo'
The following object(s) are masked from 'package:base':
as.Date
Loading required package: maxLik
Loading required package: miscTools
> z<-odbcConnectExcel("C:\\2008 Racedata.xls")
> y<-sqlFetch(z,"Sheet1")
> x<-mlogit.data(y,choice="winner",shape="long",id.var="datekey",alt.var="horseno")
Error in `row.names<-.data.frame`(`*tmp*`, value = c("1.8", "1.11", "1.6", :
duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique values when setting 'row.names': ‘10.2’, ‘10.4’, ‘10.8’, ‘100.7’, ‘101.1
你能請張貼在最起碼'STR(Y)'的結果嗎?你能否告訴我們過去對於不同數據集的類似分析是否有效?請閱讀http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example,並考慮相應地編輯您的文章... –
我不認爲這是一個文件打開錯誤。你的錯誤發生在'mlogit.data'中,它對數據格式非常特別。也就是說,'mlogit'軟件包有**全面的**手冊和小插圖,用於描述數據的外觀。將您的數據格式與http://cran.r-project.org/web/packages/mlogit/mlogit.pdf比較 – Andrie