A very general solution:

#x is standard normal
> x <- rnorm(100,0,1)

#Would need this if x included missing values
>x <- na.omit(x)

#x and cdf in a data frame
> df <- data.frame(x,cdf=rank(x)/length(x))

#Sort for display and plotting
> df <- df[order(df$x),]

#Plot cdf as a step function
> with(df,plot(x,cdf,type="s"))

# Quantiles (first 6 records)
> head(df)
      x  cdf
12 -2.1 0.01
47 -2.0 0.02
37 -1.7 0.03
72 -1.7 0.04
60 -1.4 0.05
83 -1.3 0.06

#Selected quantiles, e.g., 
#median and interquartile range
> quantile(df$x,c(0.25,0.50,0.75))
  25%   50%   75% 
-0.71  0.10  0.93 


*************************************************
Glen A. Sargeant, Ph.D.
Research Wildlife Biologist/Statistician
Northern Prairie Wildlife Research Center
8711 37th Street SE
Jamestown, ND  58401

Phone: (701) 253-5528
E-mail:  glen_sargeant@usgs.gov
FAX:     (701) 253-5553
*************************************************



From:
Jane Shevtsov <jane.eco@gmail.com>
To:
r-sig-ecology@r-project.org
Date:
09/04/2010 12:37 AM
Subject:
[R-sig-eco] p-Function for Empirical Distributions
Sent by:
r-sig-ecology-bounces@r-project.org



Does R have a p-function for empirical distributions? In other words,
how can I find out what fraction of the values in my data set are
smaller than a given value?

-- 
-------------
Jane Shevtsov
Ecology Ph.D. candidate, University of Georgia
co-founder, <www.worldbeyondborders.org>
Check out my blog, <http://perceivingwholes.blogspot.com>Perceiving Wholes

"The whole person must have both the humility to nurture the
Earth and the pride to go to Mars." --Wyn Wachhorst, The Dream
of Spaceflight

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



	[[alternative HTML version deleted]]

