s-news
[Top] [All Lists]

Re: vectors definition and storage

To: Stefano Sofia <stefano.sofia@usa.net>
Subject: Re: vectors definition and storage
From: Spencer Graves <spencer.graves@PDF.COM>
Date: Tue, 22 Apr 2003 05:57:59 -0700
Cc: s-news@lists.biostat.wustl.edu
References: <116HDVisE2896S08.1050999510@uwdvg008.cms.usa.net>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
Comments inline:

Stefano Sofia wrote:
Dear Splus users,
I do need some advices about vectors definition and storage.

I am building a quite big procedure where many vectors and matrices are
involved. Within this procedure there is a for loop (of length n), and because of at each step I want to store all the vectors and matrices, I
use the following structure:

array(NA, dim = c(n, number of rows, 1)) or array(NA, dim = c(number of rows,
1)) for the vectors and array(NA, dim = c(n, number of rows, number of columns)) or array(NA, dim =
c(number of rows, number of columns)) for the matrices.

For some reasons it happens that vectors are stored not correctly: not vertically (for example of dimension 13 by 1) but horizontally (i.e. of dimension 1 by 13).
In the function below reported, the vector E4iniz is correctly evaluated
(dimension (14 by 1), but with
E6iniz <- E4iniz[(2:14), ]

 E6iniz <- E4iniz[(2:14), ,drop=F ]
# drop=T, the default, reduces the dimension of the array

I hope this solves the problem without me reading the rest of your code.
Best Wishes,
spencer graves
<snip>


<Prev in Thread] Current Thread [Next in Thread>