maximusyoda
maximusyoda

Reputation: 615

How can I convert to short form of months instead of full names?

I have this time dataframe

3/31/2001 8:15
4/31/2001 8:25
2/31/2001 8:45
4/31/2001 8:55

Which I am converting into months in a different column using this line of code

all$month<-strftime(as.Date(all$time, format="%m/%d/%Y %H:%M"), "%B")

The result I get is of the form:

March
April
February
April

But I would like to get only the short form of the month names, i.e.

Mar
Apr
Feb
Apr

How can I implement it?

Upvotes: 1

Views: 87

Answers (1)

Thomas
Thomas

Reputation: 44575

Use a lowercase "b":

> strftime(as.Date("3/31/2001 8:15", format="%m/%d/%Y %H:%M"), "%b")
[1] "Mar"

Upvotes: 3

Related Questions