Hi Kyran, Please reply via the list - you'll get more answers that way :)
My example had the data in vectors, you are using a data.frame. Try replacing the relevant bits of your code (below) with these lines and see if that helps... rich.lm ~ lm(Chao1 ~ log(N.obs), data=table1) smooth.effort <- seq(0,54,0.1) lines(smooth.effort, predict(rich.lm, newdata=list(N.obs=smooth.effort)), col="red") Michael On 23 September 2010 18:06, Kyran Staunton <staunto...@gmail.com> wrote: > Ok so using your additions my script is...... > > library(adehabitat) > in.dir = in.dir="D:/R output/Richness/BK12SR.csv" > out.dir = "D:/R output/Richness/" > table1= read.csv(file =in.dir) > > y_range <- range(1:15) > x_range = range(0,60) > > png(filename="D:/R output/Richness/BK12SR.png", height=800, > width=1500, bg="white") > par(mfrow = c(1, 1), pty = "m", ps=15,cex.main=0.9,mar=c(5,7,4,7)) > > plot(table1$Chao1~table1$N.obs, ann=FALSE, axes=TRUE, ylim=y_range, > xlim=x_range, cex=1) > rich.lm <- lm(table1$Chao1~ log (table1$N.obs)) > smooth.effort <- seq(0,54,0.1) > lines(smooth.effort, predict(rich.lm, > newdata=list(table1$N.obs=smooth.effort)), col="red") > > title(xlab= "Samples") > title(ylab= "Chao1 (mean)") > box() > dev.off() > > #I have 54 samples (N.obs) and about 14 species (Chao1) > > R won't run the line as it states...... > > Error: unexpected '=' in "lines(smooth.effort, predict(rich.lm, > newdata=list(table1$N.obs=" > > Can you please decipher this error, > > Thank you very much for your time > > Kyran. > > On 23 September 2010 17:36, Michael Bedward <michael.bedw...@gmail.com> wrote: >> OK, assuming a trend in estimated spp richness vs log(effort) you >> could do this... >> >> plot(effort, richness) >> rich.lm <- lm( richness ~ log(effort) ) >> smooth.effort <- seq(1, 10, 0.1) # or whatever is appropriate >> lines( smooth.effort, predict(rich.lm, >> newdata=list(effort=smooth.effort)), col="red" ) >> >> Is that the sort of thing that you're after ? >> >> Michael >> >> >> On 23 September 2010 17:07, Kyran Staunton <staunto...@gmail.com> wrote: >>> Sorry Michael, >>> >>> Yes it surely is, Chao1 species richness increase per sampling effort >>> run through fossil. >>> >>> cheers, >>> >>> Kyran >>> >>> On 23 September 2010 16:58, Michael Bedward <michael.bedw...@gmail.com> >>> wrote: >>>> Hello Kyran, >>>> >>>> Some more details of your data would be helpful. For example, is it >>>> cumulative species count over time ? >>>> >>>> Michael >>>> >>>> On 23 September 2010 15:05, Kyran Staunton <staunto...@gmail.com> wrote: >>>>> Hi, >>>>> >>>>> I am trying to fit a logarithmic trendline to a scatterplot of a >>>>> species accumulation curve. I've tried abline, lines, curve and >>>>> scatter.smooth but none of these work. >>>>> >>>>> Can anyone help please, >>>>> >>>>> Kyran >>>>> >>>>> ______________________________________________ >>>>> 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. >>>>> >>>> >>> >> > ______________________________________________ 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.