[R] how to determine/assign a numeric vector to "Y" in the cor.test function for spearman's correlations?

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Jul 20 13:01:24 CEST 2007



G. wrote:
> Hello to all of you, R-expeRts!
> I am trying to compute the cor.test for a matrix that i labelled mydata
> according to mydata=read.csv...
> then I converted my csv file into a matrix with the 
> mydata=as.matrix(mydata)
> NOW, I need to get the p-values from the correlations...
> I can successfully get the spearman's correlation matrix with:
> cor(mydata, method="s", use="pairwise,complete,obs")
> but then if I try the 
> cor.test(mydata, method="s", use="pairwise.complete.obs")
> i always get an error message as follows:
> the "y" argument is missing and does not have any default value assigned... 
> (excuse my translation)
> WHAT SHOULD I DO???
> HOW CAN I DEFINE "Y" AS A NUMERIC VECTOR???????????
> thanx guys, i just can't express myself as a computer would...
> G :)


You have to specify two vectors for the test, e.g.:

   cor.test(mydata[,1], mydata[,2], method = "s",
     use = "pairwise.complete.obs")

See the help page ?cor.test

Best,
Uwe



More information about the R-help mailing list