THANK you for the help!! One more question. Being I need to compare 4 different wells, I like to have them all at the same scale which I can do with the ylim=c(min,max). But so the low concentrations don't get washed out, I like to plot the y axis in log format. ie 0.001, 0.010, 0.100. Below is the code I have so far.
Thanks in advance. setwd("c:/R") mydata <-read.csv("http://doylesdartden.com/R/2014_02_data.csv", sep=",") attach(mydata) plot(Arsenic~Year,data=mydata, subset = Well.ID %in% c("MW-1", "D_Arsenic"), col=ifelse(D_Arsenic, "black", "red"), ylab = "mg/L",xlab = "", pch=ifelse(D_Arsenic, 19, 17), cex = 1.5, ylim=c(0, 0.1)) subset<-Well.ID %in% c("MW-1", "D_Arsenic") lines(Arsenic[subset]~Year[subset]) #Add title title(main="MW-1") On Tue, Apr 8, 2014 at 12:52 AM, Frede Aakmann Tøgersen <fr...@vestas.com>wrote: > Well the lines() function has a subset argument as does plot() so why not > do this? > > lines(EMD ~ Year, data = mydata, subset = Well.ID %in% c("MW-1", "D_EMD")) > > And yes lines() also have a data argument so why do you not use that (as > you do with plot()) instead of attaching. > > Attaching dataframes may be a potential danger when some time in the > future you have forgot that you attached the dataframe and you have forgot > the warnings you get when attaching (making debugging difficult). > > Try this: > > > ## Define an object named Year > > ## in which case call to lines do not what you think it will do > > Year <- 1:nrow(mydata) > > > > ## or Year <- 'foo' in which case one gets an error later > > > > ## attach the dataframe > > attach(mydata) > > The following object is masked _by_ .GlobalEnv: > > Year > > Now what will happen if you do lines(EMD ~ Year)????? > > Here is the search path in my session: > > > search() > [1] ".GlobalEnv" "mydata" "package:lattice" > [4] "package:RODBC" "package:stats" "package:graphics" > [7] "package:grDevices" "ESSR" "package:utils" > [10] "package:datasets" "package:methods" "Autoloads" > [13] "package:base" > > > Yours sincerely / Med venlig hilsen > > > Frede Aakmann Tøgersen > Specialist, M.Sc., Ph.D. > Plant Performance & Modeling > > Technology & Service Solutions > T +45 9730 5135 > M +45 2547 6050 > fr...@vestas.com > http://www.vestas.com > > Company reg. name: Vestas Wind Systems A/S > This e-mail is subject to our e-mail disclaimer statement. > Please refer to www.vestas.com/legal/notice > If you have received this e-mail in error please contact the sender. > > > > -----Original Message----- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > > On Behalf Of Jim Lemon > > Sent: 8. april 2014 04:53 > > To: David Doyle > > Cc: r-help@r-project.org > > Subject: Re: [R] Plotting does odd line thing > > > > 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 > > > > ______________________________________________ > > 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. > [[alternative HTML version deleted]]
______________________________________________ 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.