how to load quarterly data from the excelsheets

I was trying to use the following code to seasonally adjusted quarterly frequency data,
in the excel file "Q.xlsx", in the first column, i have the "Date", i have them format like

however, i got the following error message
"Error in x13_prepare(list = list, na.action = na.action, iofile = iofile) :
xreg and x must be of the same frequency."

what format of Date i should use in the excelsheet to read quarterly data into R ? thanks!

#read excel to data frame
df <- read_excel("Q.xlsx")
#read time series and SA
ts <- read.zoo(df)
ts <- as.ts(aggregate(ts, as.yearqtr, sum)) #aggregate to monthly, use as.yearqtr if quarterly
sa <- seas(
  x = ts,
  xreg = genhol(cny, start = 0, end = 0, center = "calendar"),
  regression.aictest = "td",
  regression.usertype = "holiday"
sad <- final(sa)

You should not need to specify a format when reading in the data set, thought I believe you can.
If I am understanding you correctly ``df <- read_excel("Q.xlsx")` is working.

If so, you can change data types in df.




to see what R thinks are your data types. They do basically the same thing but the formatting is slightly different.

It would be very helpful if you supplied us with some sample data.

A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need. Just do dput(mydata) where mydata is your data. Copy the output and paste it here.

In general, you may find this useful: FAQ: How to do a minimal reproducible example ( reprex ) for beginners

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.