Reputation: 127
When I try to read in an excel file it always messes with the date/time.
library(openxlsx)
download.file("http://ec.europa.eu/economy_finance/db_indicators/surveys/documents/series/nace2_ecfin_1801/services_subsectors_sa_nace2.zip", destfile="services_subsectors_sa_nace2.zip")
unzip("services_subsectors_sa_nace2.zip")
bcs<-read.xlsx("services_subsectors_sa_m_nace2.xlsx", colNames=TRUE, sheet="73")
Column 1 (no name given in the original dataset) would be the date/time column. By default this colum gets given the name 73 when it enters R.
I tried
as.POSIXct(bcs$73, format="%d/%m/%Y", tz="CET")
Any help is much appreciated. Thank you :)
Upvotes: 2
Views: 7299
Reputation: 640
You can use the janitor
package, especially the function excel_numeric_to_date
.
Another option would be to use the package readxl
to read your excel file which converts automatically date columns in datetime :
library(readxl)
read_excel("services_subsectors_sa_m_nace2.xlsx", sheet="73")
Upvotes: 2