我有多个数据文件格式如下:
Condition Score Reqresponse
Z 1 b
Y 0 a
我想读取多个数据文件,获得每个条件/reqresponse 组合的平均分数,然后将该平均值制成一个主表。我希望每个数据文件在主表(或列表等)中填充一行。
这是我尝试过的
#loop reads data from source example with only 2 files named 1 and 2
for(i in 1:2)
{
n= paste(i,".txt", sep="")
data <- read.table(toString(n), header = TRUE, sep = "\t")
到目前为止还不错吧?在这之后我迷路了。
Score <- ave(x = data$Score, data$Condition, data$Reqresponse, FUN = mean)
table(Score)
}
这就是我想出的全部。我不知道表中的哪些单元格属于哪个 Condition x Reqresponse 组合,或者如何创建一个新行然后将它们输入到主表中。
顺便说一句,如果这只是一种愚蠢的方式来处理我正在做的事情,请随时指出>)