2013-10-17 12 views
1

我想檢查兩欄數據之間的相關性並將它們繪製到pdf文件中。有人能告訴我該怎麼做嗎?如何繪製PDF文件中的相關性?

diff abund_mean 
0 3444804.79 
1 847887.02 
2 93654.19 
0 721692.76 
2 382711.04 
1 428656.65 
1 120933.91 
0 157528.72 
1 159650.70 
0 124602.80 
0 90844.33 
2 501825.37 
1 270592.56 

回答

1

您是否還需要該圖或只是相關係數? 這使你與R^2散點圖:

pdf(file="myplot.pdf", width = 10, height =13) #create new pdf 
plot(diff ~ abund_mean) #see data 
abline(lm<- lm(diff ~ abund_mean)) #add regression to plot 
legend("topright", bty="n", legend=paste 
("R2 is", format(summary(lm)$adj.r.squared, digits=4))) #print the regr. coeff. on plot 
dev.off() #end of pdf creation 
summary(lm) #see all the regression coefficients (F-statistic, RSE, etc.) 
+0

調整後的R平方是不一樣的「兩列之間的相關性」。 – Roland

+0

你很可靠。也許他應該研究「lm」這個對象。我認爲沙西肝只需要相關係數和顯着性值。 – FraNut

+0

不知道爲什麼人們降低我的聲譽..我做錯了什麼?或者這只是一個愚蠢的問題? –