为什么max(Date)在R中给出2个不同的输出?

时间:2018-04-17 19:12:52

标签: r date max sqldf

我有2个数据集: - 权益和回报EXP。两者都去2018-03-31。 我尝试了两个和前者的最大(日期),我得到正确的日期2018-03-31而在后者我得到1997-04-30 我检查了两个班级,都是"日期"。 以下是我尝试的代码: -

 ReturnEXP[ReturnEXP$Date == max(ReturnEXP$Date),]
 sqldf("select * from ReturnEXP where Date = (select Max(Date) from ReturnEXP)")

ReturnEXP

 structure(list(Date = structure(c("-25537", "-25509", "-25478", 
"-25448", "-25417", "-25387"), class = "Date")), .Names = "Date", row.names 
= c(NA,6L), class = "data.frame")

 > dput(tail(ReturnEXP$Date))
 structure(c("17470", "17500", "17531", "17562", "17590", "17621"
 ), class = "Date")

权益

 structure(list(Date = structure(c(16921, 16952, 16982, 17013, 
17044, 17074), class = "Date")), .Names = "Date", row.names = c(NA, 
 6L), class = "data.frame")

在这两种情况下,我都得到了相同的结果1997 谁能告诉我怎样做才能得到2018年? 感谢

0 个答案:

没有答案