Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
fourdigityear<-c("2003/7/15","2009/6/12")
我应该如何将 4 位数年份转换为 2 位数年份,所以我最终会得到类似“7/15/03”、“12/6/09”之类的东西。
首先把你的数据变成Dates:
Date
fdy <- as.Date(fourdigityear, format='%Y/%m/%d')
然后转换格式
as.character(fdy, format = '%m/%d/%y') # "07/15/03" "06/12/09"