Description Usage Arguments Value Author(s) Examples
View source: R/SaveFireAreaFracs.R
Write the fire area fractions out to a text file named "fireAreaFracs.csv".
1 | SaveFireAreaFracs(vegChangesLocal, fireFracsLocal)
|
vegChangesLocal |
the list of 5 items returned by VegTypeChanges() |
fireFracsLocal |
the array of year-by-year fire fractions returned by SaveFireProbabilityMultipliers |
Returns a matrix fireAreaFracs[yrNdx, vtNdx] containing the same data which is written out to the text file.
Dave Conklin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## The function is currently defined as
function (vegChangesLocal, fireFracsLocal)
{
srcDataFile = vegChangesLocal[[1]]
years = vegChangesLocal[[2]]
nYr = length(years)
VTs = vegChangesLocal[[3]]
nVT = length(VTs)
vegFracs = vegChangesLocal[[4]]
outFile = "fireAreaFracs.csv"
fireAreaFracs = matrix(0, nrow = nYr, ncol = nVT)
cat(srcDataFile, file = outFile, append = FALSE)
cat("\n", file = outFile, append = TRUE)
cat("year", file = outFile, append = TRUE)
for (vtNdx in 1:nVT) cat(c(", ", VTs[vtNdx]), file = outFile,
append = TRUE)
cat("\n", file = outFile, append = TRUE)
for (yrNdx in 1:nYr) {
cat(years[yrNdx], file = outFile, append = TRUE)
for (vtNdx in 1:nVT) {
fireAreaFracs[yrNdx, vtNdx] = vegFracs[vtNdx, yrNdx] *
fireFracsLocal[yrNdx, vtNdx]
cat(c(", ", fireAreaFracs[yrNdx, vtNdx]), file = outFile,
append = TRUE)
}
cat("\n", file = outFile, append = TRUE)
}
return(fireAreaFracs)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.