首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >限制排列(permute)使用shuffleSet失败,并使用混乱运行。

限制排列(permute)使用shuffleSet失败,并使用混乱运行。
EN

Stack Overflow用户
提问于 2016-06-29 15:25:45
回答 1查看 210关注 0票数 2

我正在使用纯素包在中华人民共和国工作,但当我试图对结果执行Anova时,会遇到麻烦。我收到以下错误消息:

代码语言:javascript
复制
Error in doShuffleSet(spln[[i]], nset = nset, control) : 
  number of items to replace is not a multiple of replacement length

这个问题源于永久包的洗牌集功能。我在下面创建了一个可重复的示例。奇怪的是,洗牌功能不会造成麻烦,但洗牌集功能会带来麻烦。

在我的实验中,对4只动物进行了3次处理。动物按不同的顺序接受治疗。每天收集5份样品。

我想改变我对动物的观察,而不是它们之间的观察。因此,我使用AnimalID作为块。

我想改变几天(在我的实际实验中,动物多次接受相同的治疗),但在一天内保持测量不变。因此,我选择自由地改变每一天,在几天内没有变化。

代码语言:javascript
复制
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)

问题似乎出在问题所在。因为这很管用

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-30 05:01:27

关键问题似乎是nset = 1:生成置换,shuffleSet工作,但是打印结果失败,因为一个集合被丢弃到一个向量中,而print需要一个矩阵。你可以得到置换,你可以使用置换,但你不能print它。

我们得解决这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38103922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档