[R] date format in xyplot
John Kane
jrkrideau at inbox.com
Tue Aug 18 15:07:09 CEST 2015
Hi Christine,
I am afraid I cannot help as it 'appears' fine here
I get an x-axis witih
Oct 01 Oct 15 Nov 15 Dec 01
I don't normally use lattice but the dates seem reasonable to me
Do a str(Raw) and check if Date1 is actually a date in your orginal data. It is one here but who knows with R :)
John Kane
Kingston ON Canada
> -----Original Message-----
> From: r-help at r-project.org
> Sent: Mon, 17 Aug 2015 21:15:39 -0700
> To: r-help at r-project.org
> Subject: [R] date format in xyplot
>
> To whom it may concern,
>
> I have tried to plot some numbers against time with the time on the
> X-axis shown as "Jan", "Feb", etc.
>
> I used the following commands:
> Raw<-structure(list(Date = structure(c(6L, 7L, 2L, 4L, 12L, 9L, 7L,
> 2L, 4L, 12L), .Label = c("1/10", "1/11", "11/11", "12/11", "13/10",
> "19/9", "2/10", "2/11", "20/9", "26/11", "29/10", "29/11", "30/11",
> "31/10", "4/10", "6/10"), class = "factor"), Year = c(2002L,
> 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L, 2002L
> ), Station = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
> 2L), .Label = c("E", "F", "H", "I"), class = "factor"), Abun = c(3.42,
> 1.33, 3.67, 3.67, 3.92, 2.17, 2.5, 1.67, 6.33, 0.67), Date1 =
> structure(c(16697,
> 16710, 16740, 16751, 16768, 16698, 16710, 16740, 16751, 16768
> ), class = "Date")), .Names = c("Date", "Year", "Station", "Abun",
> "Date1"), row.names = c(NA, 10L), class = "data.frame")
>
> Raw$Date1<-as.Date(Raw$Date,"%d/%m")
> xyplot(Abun~Date1|as.factor(Year),Raw,type="p",xlab=list("Month",cex=1.5),ylab=list("Abundance",cex=1.5),cex=2,pch=c(16,16,21),col=c("Black","Grey","Black"),strip=strip.custom(bg='white'),format="%B-%d")
>
> The date format shown on X-axis was just "10-1", "10-15"
>
> I should be grateful if any one could help indicating what has gone
> wrong?
>
> Regards,
> Christine
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!
More information about the R-help
mailing list