2017-10-13 64 views

回答

2

查看as.Date函數的文檔,然後在日期對象上使用format函數(例如%Y是4位年份,%d是日期,%b是月份縮寫)。我假設「六月」是「君」,因爲其他月份是縮寫:

# the raw strings: 
> (inString <- c("May-08-2010", "Apr-09-2010", "Jun-02-2010")) 
[1] "May-08-2010" "Apr-09-2010" "Jun-02-2010" 

# convert to date object: 
> (inDates <- as.Date(inDates, format = "%b-%d-%Y")) 
[1] "2010-05-08" "2010-04-09" "2010-06-02" 

# format using format function: 
> format(inDates, "%m/%d/%Y") 
[1] "05/08/2010" "04/09/2010" "06/02/2010"