wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Joris Meys
> Sent: Friday, June 18, 2010 5:08 PM
> To: Iuri Gavronski
> Cc: r-help
> Subject: Re: [R] Non-procedural access to columns of a ma
On second thought, the addition only works in the case of a square matrix :
x = matrix(c(11,12,13,1,
21,22,23,3,
31,32,33,2,
41,42,43,1,
51,52,53,3),byrow=T,ncol=4)
> diag(x[,x[,4]])
[1] 11 23 32 41 53
works, but
> diag(x[,x[,4]]) <- diag(x[,x[,4]])+5
> x
[,1] [,2] [,3] [,4]
[1,] 11 12
> diag(x[,x[,4]])
[1] 11 23 32
> diag(x[,x[,4]]) <- diag(x[,x[,4]])+5
> x
[,1] [,2] [,3] [,4]
[1,] 16 12 131
[2,] 21 22 283
[3,] 31 37 332
Cheers
Joris
On Fri, Jun 18, 2010 at 8:58 PM, Iuri Gavronski wrote:
> Hi,
>
> I would like to have an index for a column
3 matches
Mail list logo