[R-sig-eco] correlation

Sarah Goslee sarah.goslee at gmail.com
Sun Jan 8 18:07:42 CET 2012


Hi,

You need to plot the data before you can add an abline to it.
Also, abline doesn't work with the raw data: you need to
either supply coefficients or a regression.

plot(SiO4,density) #plots the raw data
abline(lm(density ~ SiO4)) # draws the regression line, for example

Since you are interested in the *rank* relationship, you might
want to use rank() on the data before plotting, and before lm().

Sarah

On Sun, Jan 8, 2012 at 11:41 AM, Mahnaz Rabbaniha <rab.mahnaz at gmail.com> wrote:
>  Dear r-sig-ecology group,
>>
>> I am trying to find correlation between two variables. whereas they are non-normal used Spearman in this way:
>
>>  cor.test(SiO4,density,method="spearman")
>        Spearman's rank correlation rho
> data:  SiO4 and density
> S = 5263.445, p-value = 0.1184
> alternative hypothesis: true rho is not equal to 0
> sample estimates:
>      rho
> -0.296415
>> plot(SiO4, density)
>
>
> but i cant draw the line and in others same files, the problem is same
> and what is meaning this message:
>
> library (graphics)
>> abline(density~SiO4)
> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
>  plot.new has not been called yet
>
>
>
> .
>>
>> Many thanks in advance,
>> mahnaz



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-sig-ecology mailing list