Question: I want to delay between each output result for say, 1 second. The very last line of the following code is throwing an error "Use of undeclared identifier 'dealCard'", but I have declared it in the header file as shown below.

```
- (IBAction)startPause:(id)sender
{
    if ([self.deal length]>cardNum) {
        timer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(dealCard) userInfo:nil repeats:NO];
        card.text = [NSString stringWithFormat:@"%i",cardNum];
        [timer fire];
    }
}

- (void) dealCard{
    NSLog(@"dealCard: %d: ", cardNum+self.randCut);
    cardNum=cardNum + 1;
    [self startPause:(id)dealCard];
}

```

header file is next.

```
- (IBAction) startPause:(id)sender ;
- (void) dealCard;

```

Answer: 
The mean of a boolean is the percentage that are true, so something like this should do it:

```
mean(data$scaled.score >= cut.ss, na.rm=TRUE)

```

As in your comment, yes, that's exactly what you need to do. I'd choose to access `scaled.score` slightly differently, but no real difference.

```
gs <- sort(unique(df.ex$grade.equivalent))
ps <- sapply(gs, function(cut.ge) {
  mean(df.ex$scaled.score[df.ex$grade.equivalent>=cut.ge] >= 301, na.rm=TRUE)
})
data.frame(gs, ps)

#  gs        ps
# 1.3 0.2000000
# 1.4 0.2222222
# 1.7 0.2500000
# 2.2 0.2857143
# 2.3 0.2000000
# 2.4 0.2500000
# 2.5 0.3333333
# 2.7 0.5000000
# 3.1 1.0000000

```

I don't think this is the kind of thing that will work well with `plyr`'s split-apply-combine methodology, because you can't split the data into discrete subsets for each grade-equivalent, instead, some rows will appear in multiple subsets. 

Another option would be to split the scores (or the entire data frame, if needed) yourself into the desired sections, and then to apply whatever functions you wanted; this would be the same methodology as `plyr`, though more by hand.

```
scores <- lapply(gs, function(x) df.ex$scaled.score[df.ex$grade.equivalent>=x])
sapply(scores, function(x) mean(x>301, na.rm=TRUE))

```

And a final option would be to put them in order to start with and then compute a cumulative mean, and remove the duplicated `grade.equivalent` values, like this.

```
df2 <- df.ex[rev(order(df.ex$grade.equivalent)),]
df2$perc <- cumsum(df2$scaled.score>301)/1:nrow(df2)
df2 <- df2[nrow(df2):1,c("grade.equivalent", "perc")]
df2[!duplicated(df2$grade.equivalent),]

```
```
 with(df.ex, tapply(scaled.score, INDEX=grade.equivalent, 
                   FUN=function(s) 100*sum(s>301)/length(s) ) )
#1.3 1.4 1.7 2.2 2.3 2.4 2.5 2.7 3.1 
#  0   0   0  50   0   0   0   0 100 

```