Difficulty Replacing a Row of a Data Frame
not off the top of my head, but if you provide a reproducible example (cut and paste into R) then I may be able to help you.
On Tue, Mar 17, 2009 at 10:44 AM, Bill Cunliffe <bill at elevationllc.net> wrote:
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]]
______________________________________________ R-help at r-project.org 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.
Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis