如何将 date object
的格式从 "%Y/%m/%d"
更改为 "%d/%m/%Y"
。我试过 below-mentioned code
没有太大成功。
as.Date(bank$date,format="%d/%m/%Y")
[1] "2007-11-02" "2007-11-09" "2007-11-16" "2007-11-23" "2007-11-30" "2007-12-07"
[7] "2007-12-14" "2007-12-20" "2007-12-28" "2008-01-04" "2008-01-11" "2008-01-18"
[13] "2008-01-25" "2008-02-01" "2008-02-08" "2008-02-15" "2008-02-22" "2008-02-29"
感谢您的帮助。
答案 0 :(得分:1)
date <- as.Date("2007-11-02")
new_date <- format(date, "%d/%m/%Y")
new_date
#> [1] "02/11/2007"
由 reprex package (v2.0.0) 于 2021 年 7 月 1 日创建