I'm

**extremely**new to using R and have been battling to process some data using an iterative function. I just wondered if anyone might be able to give me a hand with it.

To try to make things clearer (and because I don't know how to explain it any other way) I have a set of data which looks a little like this:

NAME VALUE

Tom 4

Tom 16

Tom 2

Tom 10

Tom 12

Tom 3

Tom 4

Jill 10

Jill 20

Jill 16

Jill 1

Jill 13

Jill 2

For each "person" I am trying to calculate a baseline value produced by taking the mean of their data set +/- 1.5 standard deviations, removing any values outside this range from thier data set, and repeating the process until no values fall outside this range. The final mean will become my baseline.

I have been playing with all kinds of "while" and "if" functions but so far I don't feel like I'm even close. Any advice or links to good easily to follow resources would be very much appreciated.

Adam