Skip to content
Back to formatted view

Raw Message

Message-ID: <1390337507.5025642.1496894248776@mail.yahoo.com>
Date: 2017-06-08T03:57:28Z
From: Felipe Carrillo
Subject: time series x axis labels

I hope this is the appropriate list for this type of question
Consider the dataset below:I have a column DOC with values from 3 to 101and those are the values that I want to show on my x axis, howeverI only get 3, 3.1, 3.2 and so on. I tried to change those values with xlim(3, 101) but I getthe following error:Error in unit(x, default.units) : 'x' and 'units' must have length > 0
question: Which argument is needed in the ts() call to make the x axis showbreaks every 7 days starting with 3?
wt <- structure(list(DOC = c(3, 10, 17, 24, 31, 38, 45, 52, 59, 66,?73, 80, 87, 94, 101), AvgWeight = c(1, 1.66666666666667, 2.06666666666667,?2.275, 3.83333333333333, 6.2, 7.4, 8.5, 10.25, 11.1, 13.625,?15.2, 16.375, 17.8, 21.5), PondName = structure(c(1L, 1L, 1L,?1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "Pond01", class = "factor"),?? ? SampleDate = structure(c(1182585600, 1183190400, 1183795200,?? ? 1184400000, 1185004800, 1185609600, 1186214400, 1186819200,?? ? 1187424000, 1188028800, 1188633600, 1189238400, 1189843200,?? ? 1190448000, 1191052800), class = c("POSIXct", "POSIXt"))), .Names = c("DOC",?"AvgWeight", "PondName", "SampleDate"), row.names = c(NA, 15L), class = "data.frame") ?
wt$SampleDate <- as.Date(wt$SampleDate) ?wt
library(forecast)library(ggplot2)pond <- ts(wt$AvgWeight,start=3,frequency=52)pond?d.arima <- auto.arima(pond)d.forecast <- forecast(d.arima, level = c(95), h = 3)d.forecast

autoplot(d.forecast) + xlim(7, 101)Error in unit(x, default.units) : 'x' and 'units' must have length > 0

Take a look at the attached plot

-------------- next part --------------
A non-text attachment was scrubbed...
Name: timeseries.png
Type: image/png
Size: 4042 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170608/7633f1ea/attachment.png>