我写了一个使用ggplot2生成图的脚本,并且在每个图中都有多个x轴值,并且它们中的每一个在y轴上有多个值,这个轴。我将以另一种方式提出问题:我有一个数据框中的多个子集,在for循环中生成,我如何控制for的循环以便生成另一个包含在每个数据框中的数据框行(以前的数据帧的第一列的值)对ggplot2中的特定数据执行统计测试
for (x in phy) {
print(x)
test<-subset(t, Phylum==x)
dat <- melt(test, measure=c("A","C","G","T","(A-T)/(A+T)","(G-C)/(G+T)",
"(A+T)/(G+C)"))
unitest <- unique(c(test$Class))
#print(nrow(test))
i <- 1
for(y in unitest) {
towork <- subset(test, Class==y)
# here i want to create a data frame that will contain (in each row, the
# value of the first column of the towork subset for each y)
# atest=wilcox.test(towork$A,towork$A, correct=FALSE)
# print(paste(paste(y,towork$A),towork$A))
}
}
input:
e.g
class1:
0.268912 0.158921 0.214082 0.358085
1.680946 0.314681 0.210526 0.166895
0.286945 0.322006 0.147361 0.243688
class2
0.293873 0.327516 0.156235 0.222376
0.327430 0.308667 0.135710 0.227695
0.301488 0.326511 0.125865 0.246022
0.310980 0.308730 0.148861 0.231429
我想新的数据帧在每一行中包含每个类的第一列。
output
e.g
1st row: 0.268912 1.680946 0.286945
2nd row:0.293873 0.327430 0.301488 0.310980
等... ,然后包含在每个其他数据帧的行的每个类 等的第2列...
比我想在每2行的执行统计测试新的数据框架(例如Wilcoxon Rank Sum Test)并获得结果。
任何帮助将提前意识到
Hello , i came up with an idea , but i need your help to do it.
first the data is in a large text file and i will upload it if you want , my idea is : create a function that take 2 argument :
1.the name of the column which should be used for grouping the data (e.g. phylum, or class)
2. the name of the column containing the data to test (e.g. A,C,G,T)
and i will test the data for each phylum first , and if i want i will test it for each class in each phylum.
that's mean,i will take the A column for first phylum and A column for 2nd phylum and make the wilcox.test on them , and i will make the process for each common column in each phylum. and then i will use a subset function to test the classes inside each phylum.
give me your opininon with this ??
日Thnx。
@abd - 样品输入数据和预期输出。使用'dput'来运行代码所需的任何对象。 – Chase 2011-03-30 13:12:23
@蔡斯:谢谢你的回复。 每个y包含以下varaibles:ACGT 如0.268912 \t 0.158921 \t 0.214082 \t 0.358085 \t -0.142223 \t 0.096408 \t 1.680946 0.314681 0.210526 \t \t 0.166895 \t 0.307898 \t 0.010895 – weblover 2011-03-30 13:41:20
@Chase:感谢您的回复,我刚才编辑的问题,并忘记我以前的评论,在此先感谢 – weblover 2011-03-30 13:53:01