Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.A41.4.44.0304210824340.124622-100000@homer03.u.washington.edu>
Date: 2003-04-21T15:25:50Z
From: Thomas Lumley
Subject: How to assigen column of matrix
In-Reply-To: <HDEPJCAKDEJMEEHKJOKECEIHCAAA.myao@ou.edu>

On Mon, 21 Apr 2003, Minghua Yao wrote:

>
> Hi,
>
> A simple question.
>
> I want to assign values to columns (or rows) of a matrix.
>
> It seems that
> AA[,i]<-A; # A is a vector or array;
> doesn't work.
>

It seems that it does work for me:
> AA<-matrix(1:4,2)
> AA
     [,1] [,2]
[1,]    1    3
[2,]    2    4
> A<-c(10,11)
> AA[,2]<-A
> AA
     [,1] [,2]
[1,]    1   10
[2,]    2   11

if that's what you were trying to do.  Note that command lines in R don't
end with a ;, but in this case it doesn't matter.

	-thomas