On Sun, 8 Oct 2006, Thomas P. Colson wrote:
> I'm trying to calculate a cumulative area distribution (graph) of
drainage
> areas. This is defined as P(A > A*). Simple in principle. I can do this
in
> excel, with "COUNTIF", which will count the number of cells in
the row
> "area" that have area A, then determine, for each cell in the row
"area, how
> many cells exceede that area, then dividing that number by the total number
> of cells, which gives me the probability that drainage area A exceeds
> drainage area A*.
Is this ecdf() of the vector or its suitable subset? If so, it runs very
fast even for large data sets. For plotting, bear in mind that you are
generating a lot of output, though:
> t0 <- runif(100000)
> system.time(t1 <- ecdf(t0))
[1] 0.222 0.022 0.248 0.000 0.000> system.time(plot(t1, pch="."))
[1] 1.089 0.079 1.186 0.000 0.000
isn't at all bad!
>
> E.g, drainage area of 6 sq meters (One DEM grid cell) has a high
probability
> of exceedance(.99), while a drainage area of 100,000 square meters has a
low
> probability of exceedance (.001).
>
> I wish to plot this relationship, and we all know that excel is not the
tool
> of choice when working with hundreds of thousands of records. I'd like
to
> port the CAD into a few R functions that I've already developed for
other
> tests as well.
>
> So my challenge, in R, is to
> (1)count the number of rows in column "Area" that have AREA(*),
>
> (2) determine, by row, how many rows have an area greater than the area
> given in that one row
>
> (3) divide step 2 by number of rows (how can I do a row count and port that
> to a variable, as I have to do this on 10 datasets?)
>
> Thanks for any advice you can offer to this endevour
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no