我正在使用纯素包在中华人民共和国工作,但当我试图对结果执行Anova时,会遇到麻烦。我收到以下错误消息:
Error in doShuffleSet(spln[[i]], nset = nset, control) :
number of items to replace is not a multiple of replacement length这个问题源于永久包的洗牌集功能。我在下面创建了一个可重复的示例。奇怪的是,洗牌功能不会造成麻烦,但洗牌集功能会带来麻烦。
在我的实验中,对4只动物进行了3次处理。动物按不同的顺序接受治疗。每天收集5份样品。
我想改变我对动物的观察,而不是它们之间的观察。因此,我使用AnimalID作为块。
我想改变几天(在我的实际实验中,动物多次接受相同的治疗),但在一天内保持测量不变。因此,我选择自由地改变每一天,在几天内没有变化。
require(permute)
TreatmentLevels=3
Animals=4
TimeSteps=5
AnimalID=rep(letters[1:Animals],each=TreatmentLevels*TimeSteps)
Time=rep(1:TimeSteps,Animals=TreatmentLevels)
#treatments were given in different order per animal.
Day=rep(c(1,2,3,2,3,1,3,2,1,2,3,1),each=TimeSteps)
Treatment=rep(rep(LETTERS[1:TreatmentLevels],each=TimeSteps),Animals)
dataset=as.data.frame(cbind(AnimalID,Treatment,Day,Time))
ctrl=how(blocks = dataset$AnimalID,plots = Plots(strata=dataset$Day,type = "free"),
within=Within(type="none"), nperm = 999)
#this works
shuffle(60,control=ctrl)
#this giveas an error
shuffleSet(60,nset=1,control=ctrl)
shuffleSet(60,nset=10,control=ctrl)问题似乎出在问题所在。因为这很管用
dataset$AnimalDay=factor(paste0(dataset$AnimalID,dataset$Day))
ctrl=how(plots = Plots(strata=dataset$AnimalDay,type = "free"),
within=Within(type="none"), nperm = 999)
#this works
shuffle(60,control=ctrl)
shuffleSet(60,nset=1,control=ctrl)
shuffleSet(60,nset=10,control=ctrl)发布于 2016-06-30 05:01:27
关键问题似乎是nset = 1:生成置换,shuffleSet工作,但是打印结果失败,因为一个集合被丢弃到一个向量中,而print需要一个矩阵。你可以得到置换,你可以使用置换,但你不能print它。
我们得解决这个问题。
https://stackoverflow.com/questions/38103922
复制相似问题