Hello,

I'd like to automate this script a bit more and cycle several
parameters(both the species and the metric).  For example where AnnualDepth
occurs, I need to process about 12 metrics so instead of writing this
entire script 12 times once for each metric  I'd like to be able to
automatically get another metric.

Any suggestion will be greatly appreciated.

Currently running Windows XP, R 2.11.1

###############################################################################

Marsh <- cbind(SoilVegHydro, vegcode)
AnnualDepth <- Marsh[,'meanAnnualDepthAve']

cattail_0 <- Marsh[,'cattail'] == '0'  # no           need to run for 8
species, automate if possible
 cattail_1 <- Marsh[,'cattail'] == '1' # yes         need to run for 8
species

spbase.rate.d1 <- sum(cattail_1)/(sum(cattail_1) + sum(cattail_0) )
annualDepth.density <- density(AnnualDepth)    # this line needs either
interactively defined or automatically cycle thru a number of metrics

cattail.d0.density <- density(AnnualDepth[cattail_0])
cattail.d1.density <- density(AnnualDepth[cattail_1])

approxfun (cattail.d0.density$x, cattail.d0.density$y) -> cattail.d0.f
approxfun (cattail.d1.density$x, cattail.d1.density$y) -> cattail.d1.f

p.d.given.AnnualDepth <- function(AnnualDepth, spbase.rate.d1)
     {
        p1 <- cattail.d1.f(AnnualDepth) * spbase.rate.d1
        p0 <- cattail.d0.f(AnnualDepth) * (1 - spbase.rate.d1)
       p1/(cattail_0+cattail_1)
    }

x <- 1:1292
y <- p.d.given.AnnualDepth(x, spbase.rate.d1)
plot (x, y, type='l', col='red', xlab='Mean Annual Depth',
main=c("Cattail"), ylab='estimated\nProbability(cattail|AnnualDepth)')

plot (cattail.d0.density, col ='red', lty= 1, main = "")
  lines(cattail.d1.density, col = 'blue', lty=1)
  lines(annualDepth.density , col='black', lty = 1)
  legend(2000, 0.0023, c("No Cattail", "Cattail", "Mean Annual Depth"),
      col=c("red", "blue", "black"),lty=c(1))




#####################################################################################################

Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax     (305) 224 - 4147

______________________________________________
R-help@r-project.org 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.

Reply via email to