I have multiple data files formatted like so:
Condition Score Reqresponse
Z 1 b
Y 0 a
I want to read in multiple data files, get a mean score for each condition/reqresponse combo then tabulate that mean into a master table. I want each the means for each data file to populate a row in the master table (or list, whatever).
Here's what I've attempted
#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")
So far so good right? After this I get lost.
Score <- ave(x = data$Score, data$Condition, data$Reqresponse, FUN = mean)
table(Score)
}
This is all I've come up with. I don't know which cells in the table belong to which Condition x Reqresponse combo, or how to create a new row and then feed them into a master table.
By the way, if this is just a silly way to approach what I'm doing feel free to point that out >)
toStringwould be quite unnecessary.pastereturns a character value.