Re: [R] diagonal matrix construction

2004-10-12 Thread Gabor Grothendieck
Chris Ryan chrisryan at wvdnr.gov writes:

: 
: Hi, 
: 
: I have worked long and hard and looked in the manuals and am having a hard 
time constructing a diagonal
: matrix.  I can get the diagonals out of a matrix but can't construct the 
matrix with just the diagonals.  I
: have been on the web site and manuals and I think that it says to use:
: 
: dsj - diag (three = 1, nrow, ncol = 7)   three is 
the name of my matrix and dsj is where I'm trying to put it but it
: comes back:  
: 
: unused argument(s) (three ...)
: every time that I try it.  
: 
: Am I doing something wrong in trying to make this matrix?
: 
: Thank you very much for your time, Chris Ryan
:

Looking at ?diag we see that diag takes 3 arguments: 'x', 'nrow' and 'ncol'.
'three' is not one of them so it is correctly telling you that you specified
an unused argument.

diag(nrow = 7) # will create a 7x7 identity matrix.
diag(1, 7)  # same using positional rather than named arguments
diag(, 7)  # same since x defaults to 1

Look at the examples at the bottom of the ?diag page and try them out 
by running

example(diag)

at the R prompt or by just typing them in to get more insight.  Also
you might consider rereading the Introduction to R manual where it 
is covered on page 22.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] diagonal matrix construction

2004-10-12 Thread Spencer Graves
 Did you try working the examples in the diag documentation, one 
of which is as follows: 

  diag(10,3,4) # guess what?
[,1] [,2] [,3] [,4]
[1,]   10000
[2,]0   1000
[3,]00   100
(R 1.9.1 for Windows). 

 The R syntax expects three in that context to be an argument of 
the function diag.  If you want a 7x7 identity matrix, try diag(7).  
If you want something else, please study the examples in the 
documentation for diag.  If that is not adequate, let us know. 

 hope this helps.  spencer graves
Chris Ryan wrote:
Hi, 

I have worked long and hard and looked in the manuals and am having a hard time 
constructing a diagonal matrix.  I can get the diagonals out of a matrix but can't 
construct the matrix with just the diagonals.  I have been on the web site and manuals 
and I think that it says to use:
dsj - diag (three = 1, nrow, ncol = 7)   three is the name of my matrix and dsj is where I'm trying to put it but it comes back:  

unused argument(s) (three ...)
every time that I try it.  

Am I doing something wrong in trying to make this matrix?
Thank you very much for your time, Chris Ryan
Christopher W. Ryan
Black Bear Project Leader
West Virginia Division of Natural Resources
Capitol Complex, Bldg 3, Rm 824
Charleston, WV 25305
[[alternative HTML version deleted]]
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

--
Spencer Graves, PhD, Senior Development Engineer
O:  (408)938-4420;  mobile:  (408)655-4567
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html