[R] Converting characters back to Date and Time
@kw@|mmo @end|ng |rom gm@||@com
Tue Aug 31 23:23:08 CEST 2021
I'm assuming you're reading from an "*.xlsx" file. I'm not sure which
package you're using for this scenario, but my preference is 'openxlsx'. If
this is the package you're using, you could set argument 'detectDates' to
'TRUE', and then it should read them correctly.
FILE <- tempfile(fileext = ".xlsx")
data.frame(V1 = as.Date("2000-01-01")),
openxlsx::read.xlsx(FILE, detectDates = TRUE)
The first one should read the dates as numbers (days since 1900-01-01 or
1904-01-01, depending upon setup), while the second should parse them to
class "Date". I hope this helps!
On Tue, Aug 31, 2021 at 4:26 PM Eliza Botto <eliza_botto using outlook.com> wrote:
> DeaR useR,
> I read an excel column in R having Date and time (written in the same
> cell) as follow,
> 06/18/18 10:00
> 06/18/18 11:00
> 06/18/18 12:00
> In R environment, they are read as
> Is there a way to covert these characters back to the original format?
> Thank-you very much in advance.
> Eliza Botto
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help