I'm trying to export multivariate time series data from R to an excel file, but each time it excludes the column for time period. I've pulled data using APIs from the St. Louis FRED, then converted the monthly data to quarterly and converted to time series, then combined all three dataset into one time series dataset, and then exported to excel. But each time the export in excel excludes the column for quarters (or months when I don't average by quarter).
Is there a way to include the time periods in the export? For example, a column with values such as "2019 Q1"? Any help most appreciated!
Below is the code I'm using:
#Total Nonfarm Employment Washington state, Thousands of Persons, Seasonally Adjusted, Monthly
getSymbols("WANA",src="FRED")
WANA<-ts(WANA,start=c(1990,1),frequency = 12)
#Unemployment Rate WA, Seasonally Adjusted, Monthly
getSymbols("WAUR",src="FRED")
#Data goes back to 1976, so starting at 1990
WAUR<-ts(WAUR["1990-01-01/"],start=c(1990,1),frequency = 12)
#All Employees: Education and Health Services in WA, Seasonally Adjusted, Monthly
getSymbols("WAEDUH",src="FRED")
WAEDUH<-ts(WAEDUH,start = c(1990,1), frequency = 12)
DATA <- cbind(WAUR, WANA, WAEDUH) #combining all three into one dataset
Data.quarterly <- aggregate(ts(DATA,start=c(1990,1),frequency = 12),nfrequency = 4,mean) #averaging data by quarter
write.xlsx(Data.quarterly, "testdata.xlsx")