[R] averaging within columns

thomas hills thills at mail.utexas.edu
Sat Feb 26 18:17:13 CET 2005


I have a dataframe with names in the first column and wait times 
between decisions in the second column.  Since individuals make 
multiple decisions, I want the average for each individual.  For 
example, the data might look like this

name	wtime
jo		1
jo		2
jo		1
jo 		3
tim		3	
tim		2
tim		2
ro		1
ro		2
etc.

I'm hoping there is something like

mean(dataname$wtime[name])

which will just create a column with length equal to the number of 
different names (levels) and an average wtime for each.  So far though, 
I haven't had much luck figuring that one out.

Thanks.
Thomas




More information about the R-help mailing list