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,avGain[(j+1):nrow(avGain),])

 

would be a great solution as positioning is important.

 

  _____  

From: Levi Waldron [mailto:[email protected]] 
Sent: Tuesday, March 17, 2009 12:17 PM
To: Bill Cunliffe
Cc: [email protected]
Subject: Re: [R] Difficulty Replacing a Row of a Data Frame

 

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't pay close attention to how you formed b, but this of course will
only work if it has the same number of columns as avGain.


        [[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.

Reply via email to