Learn R Programming

ACCLMA (version 1.0)

calcFX: Calculates the appropriate F(X) value of each observation

Description

Calculate the F(X) of each obseravtion by summing the F(X) of the previous observation with the weight of the current observation, should be used only after the calcWeights has been used on the source matrix

Usage

calcFX(mat)

Arguments

mat
A data set that has the X,Y,Weight columns after calcWeights and reduceSameXs has been used on it

Value

Details

References

See Also

Examples

Run this code
d <- c(1,1,3,4)
e <- c(5,6,7,8)
f <- c(1,1,1,1)
mydata <- data.frame(d,e,f)
names(mydata) <- c("X","Y","Weight")
mydata<-calcWeights(mydata)
mydata<-averageSameXs(mydata)
calcFX(mydata)

## The function is currently defined as
function (mat) 
{
    mat[1, 4] = mat[1, 3]
    n <- size(mat)
    for (i in 2:n) {
        mat[i, 4] = mat[i - 1, 4] + mat[i, 3]
    }
    names(mat)[4] <- "FX"
    return(mat)
  }

Run the code above in your browser using DataLab