[英]Time Series Analysis - for negative values?
I am trying to see some trend based on the Sales figure based on Months 我正在尝试根据基于月的销售数字看到一些趋势
Amount
14997.816
26460.718
19607.54
-7612.395
78424.35
4565.6275
5338.02
8650.41
24390.235
9691.5975
168614.2575
887.25
12748.9
7651.5315
402818.9605
1912.45
113.5
11175.6245
23481.0465
10052.49
26962.1625
56399.7825
9751.879
3577.967
25698.45
24844.565
10339.175
165261.7405
460.8935
8383.212
Date
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
6/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
7/1/2010
df <- read.csv("----file path-----")
df$Date <- as.Date( df$Date, '%m/%d/%Y')
require(ggplot2)
ggplot(data = df, aes(Date, Amount)) + geom_line()
I am getting plot, which doesn't resemble a typical Time-Series Plot, is it because of the negative values in the 'Amount'? 我得到的图与典型的时间序列图不一样,是因为“金额”中的值为负值吗?
How can I plot time-series graph for the data above? 如何为上面的数据绘制时间序列图?
*sales amount is invoice + credit notes , credit notes are returned product, they carry a negative amount *销售金额为发票+贷方票据,贷方票据为退货产品,其金额为负数
The reason that you don't have a chart that resembles a time series is because your data doesn't resemble a time series. 您没有类似于时间序列的图表的原因是因为您的数据与时间序列不同。 It's easier to see with the base plotting function, that you have only two dates in your object:
使用基本绘图功能可以更容易地看到对象中只有两个日期:
plot(Amount ~ Date, data=df)
I am fairly sure that this isn't intentional. 我相当确定这不是故意的。
df
: df
:
structure(list(Amount = c(14997.816, 26460.718, 19607.54, -7612.395,
78424.35, 4565.6275, 5338.02, 8650.41, 24390.235, 9691.5975,
168614.2575, 887.25, 12748.9, 7651.5315, 402818.9605, 1912.45,
113.5, 11175.6245, 23481.0465, 10052.49, 26962.1625, 56399.7825,
9751.879, 3577.967, 25698.45, 24844.565, 10339.175, 165261.7405,
460.8935, 8383.212), Date = structure(c(14761, 14761, 14761,
14761, 14761, 14761, 14761, 14761, 14761, 14761, 14761, 14761,
14761, 14761, 14761, 14761, 14761, 14791, 14791, 14791, 14791,
14791, 14791, 14791, 14791, 14791, 14791, 14791, 14791, 14791
), class = "Date")), .Names = c("Amount", "Date"), row.names = c(NA,
-30L), class = "data.frame")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.