【发布时间】:2017-07-26 08:46:38
【问题描述】:
我有一个包含 110 行的数据框,它是来自微阵列实验表达式集对象的 pData。我想创建一个具有 2 个级别的因子向量,随机分配给行(代表实验的样本)。例如,如果有 110 行对应于实验中的 110 名受试者,我希望将 55 行设置为“G0”,将 55 行设置为“G1”。这些组用于后续功能。 我目前正在尝试以下内容,它包含在我要修改的函数中:
# makes a numeric vector of the number of subjects/rows in the pData
sml<-rep(0,length(colnames(eset))
# ‘populate’ sml with G0 & G1
sml[sample(sml,(length(sml)/2))]<-"G0"
sml[sample(sml,(length(sml)/2))]<-"G1"
label <- as.factor(sml)
如何进行采样,以使 G1 组完成 sml 的长度,并使已分配为 G0 的位置保持不变? 谢谢
【问题讨论】:
标签: r random bioconductor