Re: [R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread Levi Waldron
On Tue, Mar 17, 2009 at 12:54 PM, Bill Cunliffe wrote: > Thanks for your help. Part of the problem was that I thought I was > dealing with a data frame when it was actually an array. I forced all to be > matrices for consistency. However, I see that > > > > avGain <- rbind(avGain[1:(j-1),],b,a

Re: [R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread Bill Cunliffe
as positioning is important. _ From: Levi Waldron [mailto:lwaldron.resea...@gmail.com] Sent: Tuesday, March 17, 2009 12:17 PM To: Bill Cunliffe Cc: r-help@r-project.org Subject: Re: [R] Difficulty Replacing a Row of a Data Frame Your first example that works would just repeat the ato

Re: [R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread Levi Waldron
Your first example that works would just repeat the atomic vector to the length of the row. To replace a row with another data frame, you could use rbind: avGain <- rbind(avGain[-j,],b) Or if the positioning is important, 2) avGain <- rbind(avGain[1:(j-1),],b,avGain[(j+1):nrow(avGain),]) I didn

Re: [R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread stephen sefick
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 wrote: > I have the following data frames, avGain and retGain.  They have the same > dimensions. > > > > The following line

[R] Difficulty Replacing a Row of a Data Frame

2009-03-17 Thread Bill Cunliffe
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 ) +