Hi,
Try:

tab1 <- read.table("132p1vs132p2",sep="\t",header=TRUE)
 str(tab1)
#'data.frame':    1765 obs. of  2 variables:
# $ Sample_132p1: num  2.395 0 0.216 0 0.246 ...
# $ Sample_132p2: num  2.428 0 0.247 0 0.136 ...

plot(tab1$Sample_132p1,tab1$Sample_132p2,pch=20)
fm <- lm(tab1$Sample_132p2~tab1$Sample_132p1)
abline(fm,col="red")
#or
abline(coef=coef(fm),col="blue")
#or
abline(a=fm$coefficients[1],b=fm$coefficients[2],col="green")

A.K.


On Monday, December 30, 2013 6:19 AM, Vivek Das <vd4mm...@gmail.com> wrote:

Dear Arun,

I am trying to draw a scatter plot with the best fit line. My data is in the 
attachment. and am providing the code am using but the best fit line is not 
coming. Can you please let me know where am getting wrong.

tab=read.table("~/Desktop/Bonn_New_Pas_algo_data/results_30092013/edgeR_24122013/corr_test_PGRTvsPDGRT/132p1vs132p2",sep="\t",header=T)
> plot(tab$Sample_132p1,tab$Sample_132p2,pch=20)

Am getting the plot but now if I want the best fit line am not getting it. Can 
you guide?


----------------------------------------------------------

Vivek Das

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to