I get this error when i run my script:

Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) :

time series has no or less than 2 periods.

where in my script do i need to adjust code to get that error solved?

my script looks like this:

# load needed packages

library(readr)

library(dplyr)

library(readxl)

library(forecast)

library(doParallel) # necessary to allow the use of multiple cores

library(tsintermittent) # TSB (Teunter-Syntetos-Babai) method

library (ggplot2)

# import data

sales <- read_excel("C:/Users/jenny/Desktop/R Studio/MonthlySales1.xls")

# explore data

str(sales)

cx <- c(0, cumsum(ifelse(is.na(x), 0, x)))

cn <- c(0, cumsum(ifelse(is.na(x), 0, 1)))

rx <- cx[(2+1):length(cx)] - cx[1:(length(cx) - 2)]

rn <- cn[(2+1):length(cx)] - cn[1:(length(cx) - 2)]

rsum <- rx / rn

head(sales, n = 5)

month: Dateformat: "%B"

sales: "numeric"

options(repr.plot.width = 6, repr.plot.height = 3)

ggplot(sales, aes(x = month, y = sales)) + geom_line() + geom_smooth(method = 'lm') +labs(x = "Time", y = "Monthly Sales")

salesTS <- ts(sales$sales, frequency = 365, start = c(2019,365))

class(salesTS)

'ts'

options(repr.plot.width = 6, repr.plot.height = 5)

salesDecomp <- decompose(salesTS)

autoplot(salesDecomp)

# logging transform time series data

salesLog <- log(salesTS)

salesLogHW <- ets(salesLog)

salesLogHW

ets(x = salesLog)

sales <- sqrt(salesLogHW$dispersion)

dnorm(7, mean = coef(m1), sd = sdest)

salesLogHW <- HoltWinters(salesLog)

salesLogHW

HoltWinters(x = salesLog)

options(repr.plot.width = 6, repr.plot.height = 4)

autolayer(salesLogHW)

# forecast next year's sales

nextYearSales <- forecast(salesLogHW, h=4)

# plot

autoplot(nextYearSales)

nextYearSales