0
> a = read.csv(gzfile("cms_conf_ct_perweek.csv.gz"), as.is = TRUE)
> class(a)
[1] "data.frame"
> head(a)
    week ct
1 2006-1      0
2 2006-2      5
3 2006-3      0
4 2006-4      0
5 2006-5      0
6 2006-6      0


> tail(a)
       week ct
500 2015-32      0
501 2015-33      0
502 2015-34      2
503 2015-35      0
504 2015-36      0
505 2015-37      1

How shall I plot this time series (the column "week" represents the year and week, and the column "ct" is the value for each "week")? It doesn't work by

plot(a)

Thanks.

Jane
  • 1
  • It depends on what kind of plot you want. You can plot `ct` as a time series like `plot(as.ts(a$ct))`. You can also plot the ACF for time series using `acf()`. – Alex A. Apr 17 '15 at 17:46
  • Thanks. @AlexA. `plot(as.ts(a$ct))` doesn't show the week in the x axis, and how shall I also show that? – Jane Apr 17 '15 at 17:49
  • [This should help](http://stackoverflow.com/q/17758006/3005513) with getting `week` on the x-axis. – Alex A. Apr 17 '15 at 17:52
  • Thanks. @Alex. The number of weeks in a year is different for different year (at least for 2015, the file only contains the first 37 weeks). So I doubt frequency is the way to specify the weeks in a year. Since the file has the "week" column, how can we use the column to specify the values of the x axis? – Jane Apr 17 '15 at 18:07
  • That's right. Take a look at the answers to that question, particularly the second that uses the base plotting, and ignore any references to `frequency`. You can plot with `xaxt="n"` to suppress x-axis labels, then add custom ones using `axis()` with `a$week` for the labels. – Alex A. Apr 17 '15 at 18:09

0 Answers0