[R] I have a problem in doing the scatterplot
arun
smartpink111 at yahoo.com
Mon Dec 30 15:17:03 CET 2013
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 <vd4mmind at 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
More information about the R-help
mailing list