【发布时间】:2019-03-03 15:20:55
【问题描述】:
我有一个绘制时间序列与变量的图。但是,我想用另一个变量(对应的日期)替换图中的 x 轴值(时间序列值)。
变量已分别以日期和时间编码。我创建了另一个变量“day”来编码对应于日期的工作日。
然后我想绘制与时间序列的对比图,但在 x 轴上我希望显示“天”。
我无法针对工作日进行绘图,因为这会产生错误(变量不是数字)。
我该怎么做?我目前有这个:
household$day <- weekdays(household$Date) #Where Date is 'Date' variable
plot(as.numeric(household$Time), household$Global_active_power, type = "l", xaxt = 'n') # xaxt to remove the x-axis labels
# Step 3: add the weekdays in household$day to the x-axis ...
提前致谢。
【问题讨论】:
-
使用函数
axis