[R] x-axis order

jim holtman jholtman at gmail.com
Fri Sep 14 20:18:35 CEST 2007


This should do what you want.

x<-c(26:52,1:25)
y<-rnorm(52)+1:52

plot(seq_along(x), y, xaxt='n')
axis(1, at=seq_along(x), labels=x)



On 9/14/07, Gustaf Rydevik <gustaf.rydevik at gmail.com> wrote:
> Hi all,
>
> I have a time series which contain data collected weekly from week 26
> to week 25 the following year. How do I plot this data, so that the
> x-axis is displaying the week numbers, ordered as in the data?
>
> Thanks in advance,
>
> Gustaf
> ---
> x<-c(26:52,1:25)
> y<-rnorm(52)+1:52
> plot(x,y)   ## How do I get the x axis to be ordered by the current
> ordering of x?
>
>
>
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik
>
> ______________________________________________
> 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list