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.
我有一个字符串,它是一个日期(月、日、年)。
char <- "12/1/2014"
当我尝试将此字符串转换为日期时,我指定月、日、年
date <- as.Date(char, origin = "%m/%d/%Y")
它的格式就像我在年、日、月中输入的那样:
> date [1] "0012-01-20"
我错过了什么?
您需要使用format参数指定格式,而不是origin参数。
format
origin
(date <- as.Date("12/1/2014", format = "%m/%d/%Y")) [1] "2014-12-01"