Freewill
Freewill

Reputation: 413

Importing date from excel into R

I have imported data from an excel worksheet. one column has dates/periods in mm/dd/yy format.

I have multiple worksheets. So I used lst = readWorksheet(wb, sheet = getSheets(wb))to import the worksheets and a list is created.

I then converted the first worksheet into a dataframe

klrm=as.data.frame(lst$Arst)

But the first column which is the date column comes up as date and has 00:00:00 attached with it.

I checked this variable and it was a character variable.

Could someone help me remove those 00:00:00 ?

Upvotes: 0

Views: 665

Answers (1)

rstruck
rstruck

Reputation: 1284

in your readWorksheet call, you could try:

lst = readWorksheet(wb, sheet = getSheets(wb), dateTimeFormat = "%Y-%m-%d")

I found an example here which includes the time portion in the datetime format: http://www.inside-r.org/packages/cran/XLConnect/docs/readWorksheet

So, try setting the format for just year-month-day.

Upvotes: 1

Related Questions