[R] sum elements of dataframe

Bill Simpson wsi at gcal.ac.uk
Wed Oct 13 16:25:11 CEST 1999

I have the following problem.

Suppose I save the data from an experiment in the following way. There are
21 pairs of std and cf. Each pairing is an experimental condition, and 4
data values are saved. The conditions are run (and data saved) in random
order, though blocked such that all conditions are run once, then all in
random order a second time, and so on (let's say 3 or 4 repetitions)

What I want to do is to sum the data values of the repetitions.  For
example, suppose I have
std     cf      hit     miss    fa      cr
10      20      50      40      31      92
10	20	40	35	42	87
10	20	35	45	35	95

Then I want to sum the hit, miss, fa, and cr columns to get
10	20	125	120	108	274
totals for this condition.

So I will do
But then how do I sum data$hit etc across the reps?

If there is an alternative way to save the data to file(s) that makes this
task easier that is fine. E.g. I could save each condition to its own
file. But then I have to read in 21 files.

Thanks very much for any help.

Bill Simpson

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list