r - Time Series Analysis - for negative values? -
i trying see trend based on 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 getting plot, doesn't resemble typical time-series plot, because of negative values in 'amount'?
how can plot time-series graph data above?
*sales amount invoice + credit notes , credit notes returned product, carry negative amount
the reason don't have chart resembles time series because data doesn't resemble time series. it's easier see base plotting function, have 2 dates in object:
plot(amount ~ date, data=df)
i sure isn't intentional.
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")
Comments
Post a Comment