Learn R Programming

spsurvey (version 4.0.0)

cont.cdfplot: Plot Multiple Cumulative Distribution Functions

Description

This function creates CDF plots. Input data for the plots is provided by a data frame utilizing the same structure as the data frame named "CDF" that is included in the output object produced by function cont.analysis. Plots are produced for every combination of Type of population, subpopulation within Type, and indicator. Output from the function is placed in a PDF file.

Usage

cont.cdfplot(pdffile = "cdf2x2.pdf", cdfest, units.cdf = "Percent",
  ind.type = rep("Continuous", nind), logx = rep("", nind),
  xlbl = NULL, ylbl = "Percent", ylbl.r = NULL, legloc = "BR",
  cdf.page = 4, width = 10, height = 8, confcut = 5,
  cex.main = 1.2, ...)

Arguments

pdffile

Name of the PDF file. The default is "cdf2x2.pdf".

cdfest

Data frame utilizing the same structure as the data frame named "CDF" that is included in the output object produced by function cont.analysis.

units.cdf

Indicator for the type of units in which the CDF is plotted, where "Percent" means the plot is in terms of percent of the population, and "Units" means the plot is in terms of units of the population. The default is "Percent".

ind.type

Character vector consisting of the values "Continuous" or "Ordinal" that controls the type of CDF plot for each indicator. The default is "Continuous" for every indicator.

logx

Character vector consisting of the values "" or "x" that controls whether the x axis uses the original scale ("") or the base 10 logarithmic scale ("x") for each indicator. The default is "" for every indicator.

xlbl

Character vector consisting of the x-axis label for each indicator. If this argument equals NULL, then indicator names are used as the labels. The default is NULL.

ylbl

Character string providing the y-axis label. The default is "Percent".

ylbl.r

Character string providing the label for the right side y-axis, where NULL means a label is not created, and "Same" means the label is the same as the left side label (i.e., argument ylbl). The default is NULL.

legloc

Indicator for location of the plot legend, where "BR" means bottom right, "BL" means bottom left, "TR" means top right, and "TL" means top left. The default is "BR".

cdf.page

Number of CDF plots on each page, which must be chosen from the values: 1, 2, 4, or 6. The default is 4.

width

Width of the graphic region in inches. The default is 10.

height

Height of the graphic region in inches. The default is 8.

confcut

Numeric value that controls plotting confidence limits at the CDF extremes. Confidence limits for CDF values (percent scale) less than confcut or greater than 100 minus confcut are not plotted. A value of zero means confidence limits are plotted for the complete range of the CDF. The default is 5.

cex.main

Expansion factor for the plot title. The default is 1.2.

...

Additional arguments passed to the cdf.plot function.

Value

A PDF file containing the CDF plots.

Other Functions Required

cdf.plot

plot the CDF and associated confidence limits

Examples

Run this code
# NOT RUN {
mysiteID <- paste("Site", 1:100, sep="")
mysites <- data.frame(siteID=mysiteID, Active=rep(TRUE, 100))
mysubpop <- data.frame(
  siteID=mysiteID,
  All.Sites=rep("All Sites",100),
  Resource.Class=rep(c("Good","Poor"), c(55,45)))
mydesign <- data.frame(
  siteID=mysiteID, wgt=runif(100, 10, 100),
  xcoord=runif(100),
  ycoord=runif(100),
  stratum=rep(c("Stratum1", "Stratum2"), 50))
ContVar <- rnorm(100, 10, 1)
mydata.cont <- data.frame(
  siteID=mysiteID, ContVar=ContVar)
mypopsize <- list(
  All.Sites=c(Stratum1=3500, Stratum2=2000),
  Resource.Class=list(Good=c(Stratum1=2500, Stratum2=1500),
                      Poor=c(Stratum1=1000, Stratum2=500)))
myanalysis <- cont.analysis(sites=mysites, subpop=mysubpop, design=mydesign,
     data.cont=mydata.cont, popsize=mypopsize)
cont.cdfplot("myanalysis.pdf", myanalysis$CDF, ylbl.r="Stream Length (km)")

# }

Run the code above in your browser using DataLab