1
I’m having trouble generating and decomposing a Time Series. In this case, I was able to create a time series ts
, but when I went to decompose the series decompose
, indicates that there is an error in the Time Series, which says that the Time Series has no period, or is less than 2.
I’m using the package collection from tidyverse
.
The "dados_base
" have the 3 columns (USUARIO
;DATA
;VL_PED_PG
), where they represent Users, Purchase Date and Value respectively.
I used summarise
to summarize the data, to find the amount of sales per day.
dados_dia = dados_base %>%
group_by(DATA) %>%
summarise(QTDE_COMPRAS = n(), VALOR_TOTAL = sum(VL_PED_PG))
Then I created the Time Series.
compras = ts(dados_dia$QTDE_COMPRAS, start = c(2018,7), end = c(2019,1), frequency = 180)
But when I’m gonna decompose(decompose
) Time Series signals error.
dec = decompose(compras)
Error in decompose(purchases) : time series has no period, or has less than 2
dput
to assist the response:
structure(list(USUARIO = c(931053L, 276977L, 354508L, 909717L, 69758L,
104827L, 6600051L, 5035952L, 335505L, 340387L, 103130L, 317058L,
424447L, 6862455L, 5040771L), DATA = structure(c(17731, 17731, 17731,
17731, 17731, 17731, 17731, 17731, 17731, 17731, 17731, 17731, 17731,
17731, 17731), class = "Date"), VL_PED_PG = c(20, 20, 50, 20.32, 20,
30, 50, 50, 50, 50, 20, 20, 30, 30, 30)), row.names = c(NA, 15L),
class = "data.frame")
Hello, Isac. Wouldn’t it be better to edit the old issue instead of asking a new question?
– neves
Hello! Well, actually I don’t know, I’m new in the community and I’m learning how to use it yet. But I accept suggestions on how to ask the questions. Did you understand my problem? Should I clarify something else?
– Izak Mandrak
Use this command on
r
:dput(dados_base)
orhead(dput(dados_base))
. Then copy and paste the result into the question.– neves
Hello, I tried here, but I couldn’t. I tried on R:
teste_overflow = dput(dados_base)

compras = ts(teste_overflow, start = c(2018,7), end = c(2019,1), frequency = 60)

dec = decompose(compras)

Error in filter(x, filter) : 
 'filter' está mais comprido do que série temporal
I didn’t understand how it works.– Izak Mandrak
Suppose your database name is
meusdados
. What you need to do is just that:dput(meusdados)
Just putmeusdados
within the functiondput
.– neves
I tried:
teste_overflow = dput(dados_dia)

compras = ts(dados_dia$QTDE_COMPRAS, start = c(2018,7), end = c(2019,1), frequency = 60)
, and also: ;compras = ts(dput(dados_dia$QTDE_COMPRAS), start = c(2018,7), end = c(2019,1), frequency = 60)
but unsuccessfully... Continues with the same error. I don’t think I understand how it works. You have an example of how to usedput
?– Izak Mandrak
Read here. This can help.
– neves
Hello, I think I started to understand... would that be it?
dput(head(dados_base, 15))
structure(list(USUARIO = c(931053L, 276977L, 354508L, 909717L, 
69758L, 104827L, 6600051L, 5035952L, 335505L, 340387L, 103130L, 
317058L, 424447L, 6862455L, 5040771L), DATA = structure(c(17731, 
17731, 17731, 17731, 17731, 17731, 17731, 17731, 17731, 17731, 
17731, 17731, 17731, 17731, 17731), class = "Date"), VL_PED_PG = c(20, 
20, 50, 20.32, 20, 30, 50, 50, 50, 50, 20, 20, 30, 30, 30)), row.names = c(NA, 
15L), class = "data.frame")
– Izak Mandrak