Q:

Multiple subsets with unique counts and sums in R

I have a coding problem that is beyond my skill level.   I am hoping that someone can help me by pointing me in the direction of the tools that I need to finish this task parsimoniously. 
I am trying to create a plot of the number of unique species~cumulative area of imaginary islands.   The first point on my plot will be the the number of species on island 1, the second point would be the cumulative number of species on islands 1 & 2, the third point will be the cumulative number of species on islands 1,2,& 3 etc. 
I have 30 islands in total, and my data looks like this:
species=c("ted", "ben", "ira", "nic", "meg", "ira", "nic", "ted", "ben", "kim" )
island=c(1,1,1,2,2,2,2,3,3,3)
size=c(10,10,10,20,20,20,20,30,30,30)
dat=data.frame(species, island, size)

so far, my best approach would be to do something like this:
A=subset(dat, island="1", select=c(name, size)))
B=subset(dat, island%in% c("1", "2"), select=c(name, size))
C=subset(dat, island%in% c("1", "2", "3"), select=c(name, size))

And then I could use the length() and unique() functions to count the number of species on each imaginary island (A,B,C, etc.).   I would also need to find out the area of each imaginary cumulative island (in this case A would be size 10, B would be size 30, and C would be size 60).   
Alength=length(unique(A$species))
Asum=sum(unique(A$size)))
Blength=length(unique(B$species))
Bsum=sum(unique(B$size)))
Clength=length(unique(C$species))
Csum=sum(unique(C$size)))

But this would get very tedious for 30 islands, and I want to learn to do it the right way.   
So the end product would be a set of new imaginary islands with a number of species and an area.   Something like:
imaginaryisland=c("A","B","C")
numberofspecies=c(3,5,6) 
size=c(10, 30, 60)

Any help pointing me in the right direction would be greatly appreciated! 

A:

Here's one way, which calculates the cumulative number of species as the maximum, per island, of the cumulative number of non-duplicated species names:
data.frame(island=unique(dat$island),
           nspecies=tapply(cumsum(!duplicated(dat$species)), dat$island, max),
           size=unique(dat[, c('island', 'size')]$size))

##   island nspecies area
## 1      1        3   10
## 2      2        5   20
## 3      3        6   30

