I have reaction time and accuracy data that needs to be scored for each subject and I want to know which R package or functions would best meet my needs. Below is a snippet of what the data looks like for 2 subjects. Each row represents a single trial where the subject responds to a stimulus.

```
 date subject trialn blockcode     trialtype latency response correct
32913      15      1  practice    taskswitch    1765      205       1
32913      15      2  practice     cueswitch    4372      203       1
32913      15      3  practice cuerepetition    2523      203       0
32913      15      1      test     cueswitch    2239      205       1
32913      15      2      test cuerepetition    1244      203       1
32913      15      3      test    taskswitch    1472      203       0
32913      15      4      test     cueswitch    1877      205       1
32913      15      5      test    taskswitch    2271      203       1
30413      16      1  practice    taskswitch    1377      203       1
30413      16      2  practice    taskswitch    1648      203       1
30413      16      3  practice     cueswitch    1181      205       1
30413      16      1      test     cueswitch    1045      205       1
30413      16      2      test cuerepetition     969      203       0
30413      16      3      test     cueswitch     857      203       1
30413      16      4      test    taskswitch    1038      205       1
30413      16      5      test cuerepetition     836      203       0

```

Here's a description of what I'd like to do:

* Looking only at "test" trials, for each subject, calculate
	+ the total number of trials
	+ number of trials with latencies (i.e. reaction times) below 300ms
	+ mean latency
	+ mean correct
* Then, looking only at trials with latencies within 3 standard deviations of the subject's mean latency, calculate the mean latency for each trialtype
* Lastly, create a new data frame with all these variables and the subject ID and date