s-news
[Top] [All Lists]

[S] Q on a basic programming

To: s-news@wubios.wustl.edu
Subject: [S] Q on a basic programming
From: Mikio Kaihara <mkaihara@ichinoseki.ac.jp>
Date: Sun, 31 May 1998 17:43:07 +0900
Sender: owner-s-news@wubios.wustl.edu
Dear Sir,

  I started using the S-PLUS Ver.4.0 (for Win 95) from the last month.  I have 
a 
question on the programming(myh()).  This could be a quite easy, but I have 
wasted much time about the question(2 days).
----------------------------------------------
R is a matrix(20x20), which is already given.  I confirmed that there should be 
mistakes from the "for(i in 1:2) {
                for(k in 1:2).....".  But I donnot understand the message.
Please give me your advice.
----------------------------------------------
function()
{
        t <- array(NA, dim = c(2, 2, 1))
        t <- matrix(c(1, 0, 0, 1), ncol = 2)
        v <- array(NA, dim = c(20, 1, 2))
        for(i in 1:2) {
                v[, 1, i] <- eigen(R)$vectors[, i]
        }
        s <- array(NA, dim = c(20, 1, 2))
        s <- matrix(rep(0, 40), ncol = 2)
        for(i in 1:2) {
                for(k in 1:2)
                        s[, 1, i] <- s[, 1, i] + t[i, k, 1] %*% v[, 1, k]
                s[, 1,  ]       
        }
}
----------------------------------------------
> myh()
Error in [: Need 2 subscripts for array: .Dim=c(20, ..)
Dumped

------------------------------
Mikio 
mkaihara@ichinoseki.ac.jp  
Tel:+81-191-24-4772、; 
Fax:+81-191-24-2146
INCT, 021-8511, Japan
------------------------------
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>
  • [S] Q on a basic programming, Mikio Kaihara <=