x=c(0,1,2,3,4)
y=c(1,2,3,4,5)
r=nls(y ~ 1/(1+4*x*p),start=list(p=0))
summary(r)
xt=seq(1,1000,0.1)
yt=1/(1+4*xt*0.02860)
postscript(file="/path/to/directory/test.ps",width=7,height=7)
or svg(file="/path/to/directory/test.svg",width=7,height=7)
plot(xt,yt,'l',xlab="xlabel",ylab="ylabel")
points(x,y)
dev.off()
读tab分隔的txt:
a=read.table(file="x.txt",header=FALSE);
c=a[2:255,2]; 读第2列, 从第2行到第255行
s=sum(as.numeric(c))
d=c/s;
x=a[2:255,1]; 读第1列, 从第2行到第255行
y=d*100;
postscript(file="x.ps",width=7,height=7)
xt=x[4:100]
yt=y[4:100]
plot(xt,yt,'l',xlab="Depth",ylab="Percent")
points(xt,yt)
dev.off()