My understanding is that providing nrow and ncol, you want to create a diagonal matrix with those dimensions.

diag(pi, 6, 6)

and that by

diag(foo, 2, 2)

you really meant

diag(foo)[2]

Apologies if I misunderstood.

b

On May 14, 2009, at 10:45 AM, michael.m.spie...@gmail.com wrote:

Full_Name: Michael Spiegel
Version: 2.9.0
OS: linux
Submission from: (NULL) (204.111.252.142)


The diag() function appears to reject the first argument when it is a matrix,
and nrow and ncol arguments are also provided.

foo <- matrix(c(1:4),2,2)
foo
    [,1] [,2]
[1,]    1    3
[2,]    2    4
diag(foo)
[1] 1 4
diag(foo, 2, 2)
Error in diag(foo, 2, 2) : first argument is array, but not matrix.
is.matrix(foo)
[1] TRUE

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to