简体   繁体   中英

Convert 4 digit year to 2 digit year

fourdigityear<-c("2003/7/15","2009/6/12")

我应该如何将4位数字的年份转换为2位数字的年份,以便最终得到类似“ 7/15/03”,“ 12/6/09”的信息。

First make your data into Date s:

fdy <- as.Date(fourdigityear, format='%Y/%m/%d')

Then convert format

as.character(fdy, format = '%m/%d/%y')
#  "07/15/03" "06/12/09"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM