[R] function for cumulative occurrence of elements
Tony Plate
tplate at acm.org
Tue Jun 28 17:30:56 CEST 2005
I'm not entirely sure what you want, but is it "9 5 3" for this data? (9
"new" species occur at the first point, 5 "new" at the second, and 3
"new" at the third). If this is right, then to get "accumulation curve
when random Points are considered", you can probably just index rows of
dt appropriately.
> dd <- read.table("clipboard", header=T)
> dd[,1:3]
Point species frequency
1 7 American_elm 7
2 7 apple 2
3 7 black_cherry 8
4 7 black_oak 1
5 7 chokecherry 1
6 7 oak_sp 1
7 7 pignut_hickory 1
8 7 red_maple 1
9 7 white_oak 5
10 9 black_spruce 2
11 9 blue_spruce 2
12 9 missing 12
13 9 Norway_spruce 8
14 9 white_spruce 3
15 12 apple 2
16 12 black_cherry 1
17 12 black_locust 1
18 12 black_walnut 1
19 12 lilac 3
20 12 missing 2
> # dt: table of which species occur at which "Points"
> dt <- table(dd$Point, dd$species)
> # doc: for each species, the index of the "Point" where
> # it first occurs
> doc <- apply(dt, 2, function(x) which(x==1)[1])
> doc
American_elm apple black_cherry black_locust black_oak
1 1 1 3 1
black_spruce black_walnut blue_spruce chokecherry lilac
2 3 2 1 3
missing Norway_spruce oak_sp pignut_hickory red_maple
2 2 1 1 1
white_oak white_spruce
1 2
> table(doc)
doc
1 2 3
9 5 3
>
hope this helps,
Tony Plate
Steven K Friedman wrote:
> Hello,
>
> I have a data set with 9700 records, and 7 parameters.
>
> The data were collected for a survey of forest communities. Sample plots
> (1009) and species (139) are included in this data set. I need to determine
> how species are accumulated as new plots are considered. Basically, I want
> to develop a species area curve.
>
> I've included the first 20 records from the data set. Point represents the
> plot id. The other parameters are parts of the information statistic H'.
>
> Using "Table", I can construct a data set that lists the occurrence of a
> species at any Point (it produces a binary 0/1 data table). From there it
> get confusing, regarding the most efficient approach to determining the
> addition of new and or repeated species occurrences.
>
> ptcount <- table(sppoint.freq$species, sppoint.freq$Point)
>
> From here I've played around with colSums to calculate the number of species
> at each Point. The difficulty is determining if a species is new or
> repeated. Also since there are 1009 points a function is needed to screen
> every Point.
>
> Two goals are of interest: 1) the species accumulation curve, and 2) an
> accumulation curve when random Points are considered.
>
> Any help would be greatly appreciated.
>
> Thank you
> Steve Friedman
>
>
> Point species frequency point.list point.prop log.prop
> point.hprime
> 1 7 American elm 7 27 0.25925926 -1.3499267
> 0.3499810
> 2 7 apple 2 27 0.07407407 -2.6026897
> 0.1927918
> 3 7 black cherry 8 27 0.29629630 -1.2163953
> 0.3604134
> 4 7 black oak 1 27 0.03703704 -3.2958369
> 0.1220680
> 5 7 chokecherry 1 27 0.03703704 -3.2958369
> 0.1220680
> 6 7 oak sp 1 27 0.03703704 -3.2958369
> 0.1220680
> 7 7 pignut hickory 1 27 0.03703704 -3.2958369
> 0.1220680
> 8 7 red maple 1 27 0.03703704 -3.2958369
> 0.1220680
> 9 7 white oak 5 27 0.18518519 -1.6863990
> 0.3122961
> 10 9 black spruce 2 27 0.07407407 -2.6026897
> 0.1927918
> 11 9 blue spruce 2 27 0.07407407 -2.6026897
> 0.1927918
> 12 9 missing 12 27 0.44444444 -0.8109302
> 0.3604134
> 13 9 Norway spruce 8 27 0.29629630 -1.2163953
> 0.3604134
> 14 9 white spruce 3 27 0.11111111 -2.1972246
> 0.2441361
> 15 12 apple 2 27 0.07407407 -2.6026897
> 0.1927918
> 16 12 black cherry 1 27 0.03703704 -3.2958369
> 0.1220680
> 17 12 black locust 1 27 0.03703704 -3.2958369
> 0.1220680
> 18 12 black walnut 1 27 0.03703704 -3.2958369
> 0.1220680
> 19 12 lilac 3 27 0.11111111 -2.1972246
> 0.2441361
> 20 12 missing 2 27 0.07407407 -2.6026897
> 0.1927918
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list