Converting numeric to date issues

我怕爱的太早我们不能终老 提交于 2019-12-02 13:03:30
# First I copied the data from your question
df <- read.table(con <-file("clipboard"), header = T)
df

# Convert the format
df1 <- as.Date(df$Date1, origin = "1994-11-08")
df1
> as.data.frame(gsub("-", ".", df1))
   gsub("-", ".", df1)
1           2005.10.31
2           2009.01.11
3           2009.11.23
4           2013.05.02
5           2014.04.23
6           1994.12.17
7           1994.12.17
8           1995.04.29
9           1999.07.09
10          2006.03.22

Note, however, that there seems to be an error in the data (or at least the results you are expecting to get from the data -- how did you produce these numbers?):

  • The input for row 6 is 39
  • The input for row 7 is 39 and
  • The input for row 8 is 172

172 - 39 = 133

However you expect the dates for row 6 and 7 to be 1994.02.22 and the result for row 8 to be 1994.08.03. This is not mathematically possible, as there are 162 days between those 2 dates.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!