0
下面你以後會發現一個簡單的代碼剪斷這是能夠TP再現的錯誤,我得到:R,LME和杜克測試產生的錯誤排序
rm(list=ls(all=TRUE))
rawdata <- read.table(file = "test.csv", header=TRUE, sep=",", dec=".", stringsAsFactors = TRUE)
sets <- levels(as.factor(rawdata[,'set']))
index <- rawdata[,'set']==sets[1]
testdata <- rawdata[index,]
testdata$name <- as.factor(testdata$name)
testdata$name <- factor(testdata$name, as.character(testdata$name))
#### sorting step
sortindex <- with(testdata,order(name))
testdata <- testdata[sortindex,]
####
testdata.lme <- lme (var~name, random=~1|sample,testdata, method='REML')
testdata.lme.tuk <- summary(glht(testdata.lme, linfct=mcp(name='Tukey')))
錯誤是以下之一:
Error in glht.matrix(model = list(modelStruct = list(reStruct = list(sample = -10.3240629947066)), :
‘ncol(linfct)’ is not equal to ‘length(coef(model))’
如果省略了排序步驟,則不會生成它。但是,我需要在更大的代碼中對其他函數和數據進行排序清理。另外我想要第一個變量來表示我的控制,因此也是攔截。
同樣的問題發生在其他一些博客之前,但沒有解決,是一個數據清理問題,否則。有人有想法嗎?
我這裏使用的數據列出如下,但我認爲錯誤,儘快爲可再現的一個子集和分揀步驟包括:
name var sample set
423 10.31 1 1
423 10.39 1 1
423 10.86 1 1
421 10.75 1 1
421 10.24 1 1
421 10.27 1 1
424 10.75 1 1
424 10.75 1 1
424 10.75 1 1
423 10.14 2 1
423 10.85 2 1
423 10.48 2 1
425 10.56 1 1
425 10.67 1 1
425 10.17 1 1
426 10.50 1 1
426 10.30 1 1
426 10.29 1 1
423 10.57 3 1
423 10.07 3 1
423 10.01 3 1
428 10.26 1 1
428 10.17 1 1
428 10.72 1 1
429 10.88 1 1
429 10.93 1 1
429 10.63 1 1
423 10.38 4 1
423 10.54 4 1
423 10.25 4 1
432 10.72 1 1
432 10.62 1 1
432 10.14 1 1
434 10.45 1 1
434 10.38 1 1
434 10.41 1 1
435 10.64 1 1
435 10.21 1 1
435 10.21 1 1
423 10.46 5 1
423 10.41 5 1
423 10.13 5 1
501 10.09 1 1
501 10.86 1 1
501 10.05 1 1
503 10.22 1 1
503 10.94 1 1
503 10.38 1 1
423 10.31 1 2
423 10.39 1 2
423 10.86 1 2
421 10.75 1 2
421 10.24 1 2
421 10.27 1 2
424 10.75 1 2
424 10.75 1 2
424 10.75 1 2
423 10.14 2 2
423 10.85 2 2
423 10.48 2 2
425 10.56 1 2
425 10.67 1 2
425 10.17 1 2
426 10.50 1 2
426 10.30 1 2
426 10.29 1 2
423 10.57 3 2
423 10.07 3 2
423 10.01 3 2
428 10.26 1 2
428 10.17 1 2
428 10.72 1 2
429 10.88 1 2
429 10.93 1 2
429 10.63 1 2
423 10.38 4 2
423 10.54 4 2
423 10.25 4 2
432 10.72 1 2
432 10.62 1 2
432 10.14 1 2
434 10.45 1 2
434 10.38 1 2
434 10.41 1 2
435 10.64 1 2
435 10.21 1 2
435 10.21 1 2
423 10.46 5 2
423 10.41 5 2
423 10.13 5 2
501 10.09 1 2
501 10.86 1 2
501 10.05 1 2
503 10.22 1 2
503 10.94 1 2
503 10.38 1 2
使用'r'標記時,請使用'dput()'共享您的數據。將指針懸停在「r」標籤上以獲取更多信息。 –