Reputation: 1
I want to import an excel file in R
. The file however has columns such as Jan-13
, Jan14
and so on. These are the column headers. When I import the data using the readxl
package, it by default converts the date into numbers. So my columns which should be dates are now numbers.
I am using the code :
library(readxl)
data = read_excel("FileName", col_names = TRUE, skip = 0)
Can someone please help?
Upvotes: 0
Views: 63
Reputation: 4206
The date information is still there. It's just in the wrong format. This should work:
names(data) <- format(as.Date(as.numeric(names(data), origin="1899-01-01")), "%b%d")
Upvotes: 1