Description Usage Arguments Value Author(s) Examples
Transforms an array with a non-zero mean into an array of corresponding values normalized to the mean, and writes them out to a text file.
1 | SaveRatios(rawValues, outFile)
|
rawValues |
the original array of values - must have a non-zero mean |
outFile |
the file name and path of the output file |
the normalized array
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 (rawValues, outFile)
{
nRaw = length(rawValues)
stopifnot(nRaw >= 1)
meanVal = mean(rawValues, na.rm = TRUE)
stopifnot(meanVal != 0)
ratios = rawValues/meanVal
appendFlag = FALSE
for (ndx in 1:nRaw) {
if (is.na(ratios[ndx]))
ratios[ndx] = 0
cat(c(ndx - 1, ", ", ratios[ndx], "\n"), file = outFile,
append = appendFlag)
appendFlag = TRUE
}
return(ratios)
}
|
function (rawValues, outFile)
{
nRaw = length(rawValues)
stopifnot(nRaw >= 1)
meanVal = mean(rawValues, na.rm = TRUE)
stopifnot(meanVal != 0)
ratios = rawValues/meanVal
appendFlag = FALSE
for (ndx in 1:nRaw) {
if (is.na(ratios[ndx]))
ratios[ndx] = 0
cat(c(ndx - 1, ", ", ratios[ndx], "\n"), file = outFile,
append = appendFlag)
appendFlag = TRUE
}
return(ratios)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.