How to preserve the date column by exporting a ts or xts object from R to excel?

Asked

Viewed 61 times

1

I am working with a ts file with two variables

compib <- cbind(pimsaf, fumosaf)

head(compib)
      pimsaf  fumosaf
[1,] 77.74133 131.5189
[2,] 80.18227 131.6221
[3,] 79.77395 111.2698
[4,] 79.48862 117.7251
[5,] 79.19464 110.1054
[6,] 79.41282 105.1417

If I try directly in "write.xlsx" it does not consider the dates, if I try to turn into a dataframe it returns me distorted dates:

date   pimsaf  fumosaf
1 2002.000 77.74133 131.5189
2 2002.083 80.18227 131.6221
3 2002.167 79.77395 111.2698
4 2002.250 79.48862 117.7251
5 2002.333 79.19464 110.1054
6 2002.417 79.41282 105.1417

Is there any easier way to export ts directly to excel?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.