From simon.urbanek at math.uni-augsburg.de  Wed Sep 17 21:01:14 2003
From: simon.urbanek at math.uni-augsburg.de (Simon Urbanek)
Date: Wed Sep 17 20:00:30 2003
Subject: [Rd] possible bug in diag()
In-Reply-To: <8CBAA121CEB4D5118CB200508BB2BBEF0317E9A1@xmx8lonib.lonib.commerzbank.com>
Message-ID: <ED8C8976-E938-11D7-B881-000A959F327E@math.uni-augsburg.de>

On Wednesday, September 17, 2003, at 06:51 PM, Marsland, John wrote:

> It concerns trival diagonal matrices:
> [...]
>> diag(rnorm(1))
> <0 x 0 matrix>
>
>> diag(rnorm(1),nrow=1)
>           [,1]
> [1,] 0.4843697
>
> There's an obvious work around... but I thought it was worth notifying 
> the
> list.

I fail to see any reason for you posting this here, since this is a 
perfectly documented behavior - ?diag says:

Note:
Using 'diag(x)' can have unexpected effects if 'x' is a vector
that could be of length one. Use 'diag(x, nrow = length(x))' for
consistent behaviour.

Hence you can safely assume that the "list" needs no notification of 
this.

Cheers,
Simon


[Rd] possible bug in diag()
Simon Urbanek