[R] ggplot2 X axis levels

Felipe Carrillo mazatlanmexico at yahoo.com
Fri Feb 19 20:49:46 CET 2010


Hi all:
I've done this before with factors but can't figure how to do it with
a continuous variable. I am trying to reorder the sequence of my weeks
along the X axis. I want to start with week 27 to 52 and then 1 to 26.
I guess I could use levels along with seq() but doesn't seem to work for me.
Thanks for your help

winter <- structure(list(week = c(27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L,
35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L,
48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L,
23L, 24L, 25L, 26L), BY_2008 = c(95L, 77L, 124L, 159L, 2376L,
9480L, 17314L, 99574L, 323679L, 198211L, 93630L, 129183L, 111820L,
71260L, 35241L, 14020L, 20778L, 21694L, 15016L, 13400L, 9187L,
3607L, 2804L, 2417L, 5291L, 16216L, 898L, 558L, 709L, 972L, 61L,
372L, 3086L, 10108L, 4295L, 882L, 2593L, 36L, 233L, 243L, 0L,
70L, 272L, 308L, 134L, 40L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("week",
"BY_2008"), class = "data.frame", row.names = c(NA, -52L))
 library(ggplot2)
qplot(week,BY_2008,data=winter,geom="line",colour=I('blue'),size=I(1))
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish & Wildlife Service
California, USA






More information about the R-help mailing list