Dear Rui, thank you very much.
Your solution works perfectly. One last question: I need to write a function, with ONE value (here: a ratio) for the correct reactions divided per trials or trialCount, respectively, FOR EACH test subject. "/" means "divided by" in the following. I need the ratio correct (reactions)/trial or correct (reactions)/trialCount, respectively (because trial and trialCount are the same WITHIN test SUBJECTS; BUT they differ in length between BETWEEN test SUBJECTS!). It would be very helpful, if I had a data frame in the end in R, with one column for "trialCount"/"trial", one column for "correct reactions"(= 1) AND (more importantly) one column for "correct (= 1) answers / trialCount". legend (just as additional information) for the variable "correct": 1 = correct reaction 2 = false reaction 3 = reaction too slow 4 = reaction too fast 5 = more than one button pressed 6 = no reaction within RT window I would be very thankful for an answer! Sorry for the questions, but I am doing this for the first time! Kind regards -- View this message in context: http://r.789695.n4.nabble.com/Extracting-arithmetic-mean-for-specific-values-from-multiple-txt-files-tp4635809p4636020.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.