[R] replace a row in a matrix

Joshua Wiley jwiley.psych at gmail.com
Sun Nov 14 17:07:17 CET 2010


Hi Cassie,

If your matrix is named "X", and your vector "y", then:

X[i, ] <- y

Please read the documentation for the extraction operator.  You can
pull this up by entering the following command at the R console:

?"["

You would also probably benefit from a careful reading of this manual:
http://cran.r-project.org/doc/manuals/R-intro.pdf

I know it is 100 pages, but if you are going to use R much at all, the
time investment to read through that carefully will pay off (even if
it does not all make sense the first time through).

Cheers,

Josh


On Sun, Nov 14, 2010 at 7:59 AM, cassie jones <cassiejones26 at gmail.com> wrote:
> Dear all,
>
>
> I created a n*2 matrix and I want to replace the ith row with a vector. Can
> anyone suggest me what is the simple way to do it? Sorry for bothering you
> with such  simple question. I appreciate any hints or advice.
>
>
> Thanks in advance.
>
> Cassie
>
>        [[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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list