R: Calculates the appropriate FY value of each observation
calcFY
R Documentation
Calculates the appropriate FY value of each observation
Description
Calculates the aggregated mean Y value of each observation by summing the F(Y) value of the previous observation
with the Y*Weight of the current observation
Usage
calcFY(mat)
Arguments
mat
A matrix containing the X,Y,Weight,FX columns after the function calcWeights,reduceSameXs and calcFX has been
used on it
Value
A matrix containg the newely added FY column
Author(s)
Tal Carmi, Liat Gaziel
Examples
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)
mydata<-calcFX(mydata)
calcFY(mydata)
## The function is currently defined as
function (mat)
{
mat[1, 5] = mat[1, 2] * mat[1, 3]
n <- size(mat)
for (i in 2:n) {
mat[i, 5] = mat[i - 1, 5] + mat[i, 2] * mat[i, 3]
}
names(mat)[5] <- "FY"
return(mat)
}
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(ACCLMA)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ACCLMA/calcFY.Rd_%03d_medium.png", width=480, height=480)
> ### Name: calcFY
> ### Title: Calculates the appropriate FY value of each observation
> ### Aliases: calcFY
> ### Keywords: ~kwd1 ~kwd2
>
> ### ** Examples
>
> 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)
> mydata<-calcFX(mydata)
> calcFY(mydata)
X Y Weights FX FY
1 1 5.5 0.50 0.50 2.75
2 3 7.0 0.25 0.75 4.50
3 4 8.0 0.25 1.00 6.50
>
> ## The function is currently defined as
> function (mat)
+ {
+ mat[1, 5] = mat[1, 2] * mat[1, 3]
+ n <- size(mat)
+ for (i in 2:n) {
+ mat[i, 5] = mat[i - 1, 5] + mat[i, 2] * mat[i, 3]
+ }
+ names(mat)[5] <- "FY"
+ return(mat)
+ }
function (mat)
{
mat[1, 5] = mat[1, 2] * mat[1, 3]
n <- size(mat)
for (i in 2:n) {
mat[i, 5] = mat[i - 1, 5] + mat[i, 2] * mat[i, 3]
}
names(mat)[5] <- "FY"
return(mat)
}
>
>
>
>
>
> dev.off()
null device
1
>