Hello folks, When I use the lines function below it connects all my points but then draws a line back to the start point. Any suggestions on what is going on?? mydata <-read.csv("http://doylesdartden.com/R/test_data.csv", sep=",") attach(mydata) plot(EMD~Year,data=mydata, subset = Well.ID %in% c("MW-1", "D_EMD"), col=ifelse(D_EMD, "black", "red"), pch=ifelse(D_EDM, 19, 17), cex = 1.5) lines(EMD~Year) Thank you for your time. David [[alternative HTML version deleted]]
On 04/08/2014 12:20 PM, David Doyle wrote:> Hello folks, > > When I use the lines function below it connects all my points but then > draws a line back to the start point. Any suggestions on what is going on?? > > mydata<-read.csv("http://doylesdartden.com/R/test_data.csv", sep=",") > > attach(mydata) > > plot(EMD~Year,data=mydata, subset = Well.ID %in% c("MW-1", "D_EMD"), > col=ifelse(D_EMD, "black", "red"), pch=ifelse(D_EDM, 19, 17), cex = 1.5) > > lines(EMD~Year) >Hi David, While you will get what you expect with: lines(EMD[1:39]~Year[1:39]) I would be unnecessarily obscure in suggesting it. Try this: subset<-Well.ID %in% c("MW-1", "D_EMD") lines(EMD[subset]~Year[subset]) You haven't selected the same points for the lines function as you have for the plot function. Jim
Le 08/04/2014 04:20, David Doyle a ?crit :> Hello folks, > > When I use the lines function below it connects all my points but then > draws a line back to the start point. Any suggestions on what is going on?? > > mydata <-read.csv("http://doylesdartden.com/R/test_data.csv", sep=",") > > attach(mydata) > > plot(EMD~Year,data=mydata, subset = Well.ID %in% c("MW-1", "D_EMD"), > col=ifelse(D_EMD, "black", "red"), pch=ifelse(D_EDM, 19, 17), cex = 1.5) > > lines(EMD~Year) > > Thank you for your time. > > David > >First, there is a typo error here: pch=ifelse(D_EMD, 19, 17) Second try this to see that year data are not monotonically increasing. Then it produces the zig-zag effect that you observe: plot(1990:2000, c(rep(0, 10), 10), type="n") lines(EMD~Year) It can be seen here also: diff(Year) or diff(Year)<0 Sincerely, Marc