Ok glad this helps. Also one more hint: I am not sure what exactly uou are
trying to do there, but notice that to compute a bunch of pairwise
correlations between vectors you can simply use:
cor(X,use= "pairwise.complete.obs")
were X is a matrix or a dataframe. This will give you the whole correlation
matrix in a single line (no need for loops, etc.)
-----Original Message-----
From: gov2001-l-bounces at
lists.fas.harvard.edu [mailto:gov2001-l-
bounces at
lists.fas.harvard.edu] On Behalf Of Jill Hohenstein
Sent: Friday, March 28, 2008 10:53 AM
To: gov2001-l at
lists.fas.harvard.edu
Subject: Re: [gov2001-l] Out of bounds errors
Thank you! That helps!
Jill
On 28/03/2008 14:42, "Jens Hainmueller" <jhainmueller at gmail.com>
wrote:
well your out6<- matrix(NA,3,2) has 2 cols, so
no chance R will let
you fill
something into a 3rd column as in out6[i, 3]
<-
> different portion of the data, we get an error:
>
> out6<- matrix(NA,3,2)
>> out6[,1] <- c(103,105,107)
>> varnames <- colnames(plomin)
>> rownames(out6) <- varnames[out6[,1]]
>> for ( i in 1:3){ # Calculate teacher assessment correlations for MZ
> twins at
> 10
> + out6[i,3] <- cor(mat.cmz3[,2*(51+i)],
> mat.cmz3[,2*(50+i)+1],use="complete")
> + }
> Error in out6[i, 3] <- cor(mat.cmz3[, 2 * (51 + i)], mat.cmz3[, 2 *
(50
> + :
> subscript out of bounds
> + out6
>
>
> We've tried rewriting the code in that line in many different ways,
> such
> that the elements are reordered, we've written it from scratch,
we've
> taken
> out all the spaces and we can't seem to get it to read beyond that
'+'
sign
in that line. Does anyone have any clue as to why we would get the
error in
one but not the other?
Thanks.
Best,
Jill & Jeremy
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l