0
我有一個data table
,其中包含以下格式的日期:8/11/2016
我想將此日期格式更改爲那個:Sunday, September 11, 2016
。 有沒有一個快速和骯髒的方法來做到這一點?在R中更改日期格式,包括當天
我有一個data table
,其中包含以下格式的日期:8/11/2016
我想將此日期格式更改爲那個:Sunday, September 11, 2016
。 有沒有一個快速和骯髒的方法來做到這一點?在R中更改日期格式,包括當天
#create the variable
x <- as.Date('08/11/2016','%m/%d/%Y')
# convert to the desired format
as.character(x, '%A, %B %d, %Y')
# more about that here
# http://www.statmethods.net/input/dates.html
importDate <- as.Date('08/11/2016','%m/%d/%Y')
# format it to desired format
format(importDate, "%A %B %d %Y")
你可以有更多的可能格式的列表: https://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html
見'strftime'幫助頁面。你使用data.table的事實並不重要。 – MrFlick