Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread Liviu Andronic
On Wed, Dec 22, 2010 at 2:57 AM, Phil Spector spec...@stat.berkeley.edu wrote: To make your loop work, you need to learn about the get function. I'm not going to give you the details because there are better approaches available. First, let's make some data that will give values which can be

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread govindas
Thank you both for your suggestions. I have another question - is there a specific way to access the individual elements of a 'list' variable? i.e.  dmi = matrix(rnorm(20),4,5) soi = matrix(rnorm(20),4,5) pe = matrix(rnorm(20),4,5) y - list(dmi, soi, pe) y[[1]]   gives [,1]      

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread Liviu Andronic
On Wed, Dec 22, 2010 at 6:39 PM, govin...@msu.edu wrote: Thank you both for your suggestions. I have another question - is there a specific way to access the individual elements of a 'list' variable? i.e. dmi = matrix(rnorm(20),4,5) soi = matrix(rnorm(20),4,5) pe = matrix(rnorm(20),4,5) y

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread Bert Gunter
Have you consulted R's extensive documentation? -- in particular, An Introduction to R, which would seem like an obvious place for R newbies to start. If you had done so, you would have found your question answered there in section 6.1 on lists. -- Bert Gunter On Wed, Dec 22, 2010 at 9:39 AM,

Re: [R] matrix indexing in 'for' loop?

2010-12-22 Thread govindas
Thank you all once again .. Yeah, its working now. -- Regards, Mahalakshmi Graduate Student #20, Department of Geography Michigan State University East Lansing, MI 48824 Quoting Liviu Andronic landronim...@gmail.com: On Wed, Dec 22, 2010 at 6:39 PM,  govin...@msu.edu wrote: Thank you both

[R] matrix indexing in 'for' loop?

2010-12-21 Thread govindas
Hi, I am having trouble with matrices. I have 2 matrices as given below, and I am interested in using these matrices inside for loops used to calculate correlations. I am creating a list with the names of the matrices assuming this list could be indexed inside the 'for' loop to retrieve the

Re: [R] matrix indexing in 'for' loop?

2010-12-21 Thread Phil Spector
To make your loop work, you need to learn about the get function. I'm not going to give you the details because there are better approaches available. First, let's make some data that will give values which can be verified. (All the correlations of the data you created are exactly equal to 1.)