Thank you _SO_ much, Petr, you helped me again. That worked like a charm, exactly what I needed!
Cheers, Kathi On Thu, 27 Nov 2008 15:01:29 +0100, Petr PIKAL wrote > Hi > > [EMAIL PROTECTED] napsal dne 27.11.2008 14:20:17: > > > Dear useRs, > > > > I'm struggling again with date-related stuff: I am using R to draw water > > > levels at certain measuring > > stations. My data comes as a tab-delimited text file and looks like > this: > > > > DATUM P1 P2 > > ... > > 2006-11-16 425.21 423.99 > > 2006-12-15 425.12 423.97 > > 2007-01-16 425.16 424.06 > > ... > > > > (measurements started in July 2004 and still continue on a monthly or > bi-weekly basis) > > > > This is then plotted using this code: > > > > a<-read.table("dummy_data.tab", sep="\t", header=TRUE, na.strings=c(0)) > > x<-as.Date(a$DATUM) > > > > plot(x, a$P1, axes=FALSE, xlim=c(as.Date("2004-07-01"), > as.Date("2009-01-01")), > > ylim=c(423,428), col="red", pch=15, type="o", ylab="Kote [m a.s.l.]", > > main="Dummy Plot") > > points(x, a$P2, col="red", pch=17, type="o", lty="dotted") > > axis(2, at=423:428, tck=1, col="gray60") > > axis.Date(1, at=seq(as.Date("2004-07-01"), as.Date("2009-01-01"), > > by="month"), labels=seq(as.Date("2004-07-01"), as.Date("2009-01-01"), > > by="month"), tck=1, col="gray60") > > > > So far, I've been using this type of date format (yyyy-mm-dd) because > that was > > the only way I could > > get the whole thing to work when I started using R. However, living in > > Switzerland, I would prefer > > the dates to read 16.11.2006 i.e. dd.mm.yyyy or 16. Nov. 2006 > (preferably > > using German names for > > the months, if possible). > > > > I've used the chron package to convert my dates to day mon year (16 Nov > 2006, > > with or without > > spaces), i.e. I replaced the second line of code with: > > > > x<-format(chron(as.character(a$DATUM), format="y-m-d", out.format="day > mon year")) > > Although I am not an expert in time/date functions it seems to me > that you just want your labels to be in your preferred format. If it > is the case > > labels = format(seq(as.Date("2004-07-01"), as.Date("2009-01-01"), > by="month"), "%d.%m.%Y") > > in your call to axisDate can help you to achieve it. > > Regards > Petr > > > > > but then I can't plot them any more, because as.Date() no longer is the > > correct function and R gives > > me an error saying there is an invalid xlim-value. Can someone please > point me > > in the right > > direction? > > > > I could easily change the input data to be in dd.mm.yyyy format, if that > helps. > > > > Thanks for your help, > > > > Kathi > > > > > > -- > > DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt! > > > > ______________________________________________ > > 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. -- DropNet AG - Das Unternehmen fuer Ihren Internet-Auftritt! ______________________________________________ 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.