Reputation: 1008
I am reading a .xlsx file using R. One of the columns is called "Date" and it has the following format: "20/10/2014 12:00:00 am".
However, when I read the file using R's xlsx
package, the value becomes 41932-- class factor
. How can I read the entire column as a string (as is)? I want to be the one to convert the date/time values into POSIXlt
and/or POSIXct
classes.
Upvotes: 3
Views: 6274
Reputation: 32986
You can read into string with Hadley's readxl
package.
library(readxl)
df <- read_excel('~/Desktop/test.xlsx')
There is some support for col_type
but it's not ready yet. Instead, you can use as.POSIXct
to fix those after being read into a data.frame
e.g.
as.POSIXct(df$Date, format="%d/%m/%Y %H:%M:%S", tz="CET")
Upvotes: 1