问题
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 :)
回答1:
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")
来源:https://stackoverflow.com/questions/48804353/r-importing-xlsx-file-with-date-column