Dear Anjali, This should work: mymat <- matrix(rnorm(4*136), ncol=136) i <- 2 while(i <=121){ print(cor(t(mymat[1:2, i:(i+14)]))) i <- i+15 }
Best, Dave. -- Dave Armstrong University of Maryland Dept of Government and Politics 3140 Tydings Hall College Park, MD 20742 Office: 2103L Cole Field House Phone: 301-405-9735 e-mail: [EMAIL PROTECTED] web: www.davearmstrong-ps.com On 5/17/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hello, > > I would like to run a correlation on values in a table that > has 4 rows and 136 columns. However, I am only interested in > correlating the values in alternating blocks of 15 columns. > For example, I would like to correlate the values in row 1, > columns 2-16:31-46:61-76:91-106 with values in row 2, columns > 2-16:31-46:61-76:91-106. > > Is there a way to notate this in the cor command so that the > function will specify nonsequential values from the table? > > Thanks for any help. > > Sincerely, > > Anjali > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html