I have the following data frames, avGain and retGain. They have the same
dimensions.
The following line of code replaces row j of avGain as desired:
avGain[j, ] <- mean( retGain[jStart:j, ] )
However, the following line does not work:
avGain[j, ] <- ( avGain[j-1, ] * ( DAYS - 1 ) + retGain[j, ] ) / DAYS
If I do the following, and test to see if a or b are data frames.
a <- mean( retGain[jStart:j, ] )
b <- ( avGain[j-1, ] * ( DAYS - 1 ) + retGain[j, ] ) / DAYS
I find that a is not, but b is indeed a data frame. I guess this is part of
my problem.
Does anyone know why one works and the other doesn't, and how I can replace
a row of a data frame with another data frame?
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.