-1

我想检查两列数据之间的相关性并将它们绘制到 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
4

1 回答 1

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.)
于 2013-10-17T08:25:12.723 回答