Hello, I am having a little trouble formatting my dates correctly. When I plot something using the following commands, R plots the most recent date on the left of the figure and then earlier date on the right of the figure. Given that English is read from left to right I would like to have the dates on my figure arranged in the same way. I am sure that this is something fairly simple but I was wondering if someone could help me out. Here is a minimal example that should reproduce my problem. I've also included so data thinking that perhaps my data format was the problem. Thanks in advance! Sam Date=as.Date(test$Date, format= "%d/%m/%Y") plot(test$D.2D50.SA ~ test$Date) "Date","D.2D50.SA" 28/08/2009,60.67 28/08/2009,66.4 28/08/2009,50.19 28/08/2009,38.19 28/08/2009,50.19 12/09/2009,62.2 12/09/2009,93.77 12/09/2009,49.89 12/09/2009,106.34 12/09/2009,42.22 22/09/2009,24.15 22/09/2009,105.17 22/09/2009,15.04 22/09/2009,23.54 22/09/2009,19.6 05/10/2009,74.41 05/10/2009,34.78 05/10/2009,28.74 05/10/2009,41.29 05/10/2009,42.68 12/10/2009,46.26 12/10/2009,13.31 12/10/2009,29.95 12/10/2009,34.28 12/10/2009,74.51 19/10/2009,33.67 19/10/2009,69.86 19/10/2009,61.3 19/10/2009,21.38 19/10/2009,80.37 26/10/2009,20.69 26/10/2009,63.37 26/10/2009,70.91 26/10/2009,22.7 26/10/2009,23.89 -- ***************************************************** Sam Albers Geography Program University of Northern British Columbia 3333 University Way Prince George, British Columbia Canada, V2N 4Z9 phone: 250 960-6777 ***************************************************** [[alternative HTML version deleted]]
Sam Albers wrote:> Hello, > > I am having a little trouble formatting my dates correctly. When I plot > something using the following commands, R plots the most recent date on the > left of the figure and then earlier date on the right of the figure. Given > that English is read from left to right I would like to have the dates on my > figure arranged in the same way. I am sure that this is something fairly > simple but I was wondering if someone could help me out. Here is a minimal > example that should reproduce my problem. I've also included so data > thinking that perhaps my data format was the problem. > > Thanks in advance! > > Sam > > Date=as.Date(test$Date, format= "%d/%m/%Y") > plot(test$D.2D50.SA ~ test$Date) >You calculated Date, then plotted test$Date. Was that your intention? Duncan Murdoch> "Date","D.2D50.SA" > 28/08/2009,60.67 > 28/08/2009,66.4 > 28/08/2009,50.19 > 28/08/2009,38.19 > 28/08/2009,50.19 > 12/09/2009,62.2 > 12/09/2009,93.77 > 12/09/2009,49.89 > 12/09/2009,106.34 > 12/09/2009,42.22 > 22/09/2009,24.15 > 22/09/2009,105.17 > 22/09/2009,15.04 > 22/09/2009,23.54 > 22/09/2009,19.6 > 05/10/2009,74.41 > 05/10/2009,34.78 > 05/10/2009,28.74 > 05/10/2009,41.29 > 05/10/2009,42.68 > 12/10/2009,46.26 > 12/10/2009,13.31 > 12/10/2009,29.95 > 12/10/2009,34.28 > 12/10/2009,74.51 > 19/10/2009,33.67 > 19/10/2009,69.86 > 19/10/2009,61.3 > 19/10/2009,21.38 > 19/10/2009,80.37 > 26/10/2009,20.69 > 26/10/2009,63.37 > 26/10/2009,70.91 > 26/10/2009,22.7 > 26/10/2009,23.89 > >
> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Sam Albers > Sent: Tuesday, November 10, 2009 3:08 PM > To: r-help at r-project.org > Subject: [R] Dates plotting backwards > > Hello, > > I am having a little trouble formatting my dates correctly. > When I plot > something using the following commands, R plots the most > recent date on the > left of the figure and then earlier date on the right of the > figure. Given > that English is read from left to right I would like to have > the dates on my > figure arranged in the same way. I am sure that this is > something fairly > simple but I was wondering if someone could help me out. Here > is a minimal > example that should reproduce my problem. I've also included so data > thinking that perhaps my data format was the problem. > > Thanks in advance! > > Sam > > Date=as.Date(test$Date, format= "%d/%m/%Y")Change that to test$Data <- as.Date(...) or plot Date instead of test$Date. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com> plot(test$D.2D50.SA ~ test$Date) > > "Date","D.2D50.SA" > 28/08/2009,60.67 > 28/08/2009,66.4 > 28/08/2009,50.19 > 28/08/2009,38.19 > 28/08/2009,50.19 > 12/09/2009,62.2 > 12/09/2009,93.77 > 12/09/2009,49.89 > 12/09/2009,106.34 > 12/09/2009,42.22 > 22/09/2009,24.15 > 22/09/2009,105.17 > 22/09/2009,15.04 > 22/09/2009,23.54 > 22/09/2009,19.6 > 05/10/2009,74.41 > 05/10/2009,34.78 > 05/10/2009,28.74 > 05/10/2009,41.29 > 05/10/2009,42.68 > 12/10/2009,46.26 > 12/10/2009,13.31 > 12/10/2009,29.95 > 12/10/2009,34.28 > 12/10/2009,74.51 > 19/10/2009,33.67 > 19/10/2009,69.86 > 19/10/2009,61.3 > 19/10/2009,21.38 > 19/10/2009,80.37 > 26/10/2009,20.69 > 26/10/2009,63.37 > 26/10/2009,70.91 > 26/10/2009,22.7 > 26/10/2009,23.89 > > -- > ***************************************************** > Sam Albers > Geography Program > University of Northern British Columbia > 3333 University Way > Prince George, British Columbia > Canada, V2N 4Z9 > phone: 250 960-6777 > ***************************************************** > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
On Tue, 10 Nov 2009, Sam Albers wrote:> Hello, > > I am having a little trouble formatting my dates correctly. When I plot > something using the following commands, R plots the most recent date on the > left of the figure and then earlier date on the right of the figure. Given > that English is read from left to right I would like to have the dates on my > figure arranged in the same way. I am sure that this is something fairly > simple but I was wondering if someone could help me out. Here is a minimal > example that should reproduce my problem. I've also included so data > thinking that perhaps my data format was the problem.You defined a date variable 'Date' but you plotted the original character or factor variable 'test$Date' Try plot(test$D.2D50.SA ~ Date) -thomas> Thanks in advance! > > Sam > > Date=as.Date(test$Date, format= "%d/%m/%Y") > plot(test$D.2D50.SA ~ test$Date) > > "Date","D.2D50.SA" > 28/08/2009,60.67 > 28/08/2009,66.4 > 28/08/2009,50.19 > 28/08/2009,38.19 > 28/08/2009,50.19 > 12/09/2009,62.2 > 12/09/2009,93.77 > 12/09/2009,49.89 > 12/09/2009,106.34 > 12/09/2009,42.22 > 22/09/2009,24.15 > 22/09/2009,105.17 > 22/09/2009,15.04 > 22/09/2009,23.54 > 22/09/2009,19.6 > 05/10/2009,74.41 > 05/10/2009,34.78 > 05/10/2009,28.74 > 05/10/2009,41.29 > 05/10/2009,42.68 > 12/10/2009,46.26 > 12/10/2009,13.31 > 12/10/2009,29.95 > 12/10/2009,34.28 > 12/10/2009,74.51 > 19/10/2009,33.67 > 19/10/2009,69.86 > 19/10/2009,61.3 > 19/10/2009,21.38 > 19/10/2009,80.37 > 26/10/2009,20.69 > 26/10/2009,63.37 > 26/10/2009,70.91 > 26/10/2009,22.7 > 26/10/2009,23.89 > > -- > ***************************************************** > Sam Albers > Geography Program > University of Northern British Columbia > 3333 University Way > Prince George, British Columbia > Canada, V2N 4Z9 > phone: 250 960-6777 > ***************************************************** > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle