Description Usage Arguments Value Author(s) Examples
Constructs a 2-column sequence of yearly values, and writes it to a text file.
1 | SaveSequence(startYear, sequence, outFile)
|
startYear |
the calendar year of the first year in the sequence |
sequence |
an array of yearly values |
outFile |
the file name and path of the output file |
Returns a two-column matrix. The first column is the series of calendar years. The second column is the series of yearly values.
Dave Conklin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ## The function is currently defined as
function (startYear, sequence, outFile)
{
nSeq = length(sequence)
stopifnot(nSeq >= 1)
indexedSeq = matrix(0, nrow = nSeq, ncol = 2)
appendFlag = FALSE
for (ndx in 1:nSeq) {
if (is.na(sequence[ndx]))
sequence[ndx] = 0
cat(c(startYear + ndx - 1, ", ", sequence[ndx], "\n"),
file = outFile, append = appendFlag)
appendFlag = TRUE
indexedSeq[ndx, 1] = startYear + ndx - 1
indexedSeq[ndx, 2] = sequence[ndx]
}
return(indexedSeq)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.