将双人转换为日期

发布于 2025-01-22 14:07:53 字数 206 浏览 2 评论 0原文

在此处输入图像描述

我很难将双数据转换为日期。我想使用as_date转换日期。但是,当我应用此功能时,我会得到奇怪的输出。我认为问题将水平线放在数字下(请参阅图像)。有人知道我如何删除这条线还是逃脱?

enter image description here

I have trouble converting double data into a date. I want to convert a date by using as_date. However, when I apply this function, I am getting strange output. I think the problem lays the horizontal line under the numbers (see the image). Does someone know how I can delete this line or escape?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨笨の傻瓜 2025-01-29 14:07:53

一个选项是使用lubridate

library(lubridate)

df$date <- ymd(df$date)

# [1] "1995-10-11" "1995-01-03"

或使用strptimeas.date的组合:

df$date <- as.Date(strptime(df$date, format = "%Y%m%d"))

data

df <- structure(list(date = c(19951011, 19950103)), row.names = c(NA, 
-2L), class = "data.frame")

One option is to use lubridate:

library(lubridate)

df$date <- ymd(df$date)

# [1] "1995-10-11" "1995-01-03"

Or use a combination of strptime and as.Date:

df$date <- as.Date(strptime(df$date, format = "%Y%m%d"))

Data

df <- structure(list(date = c(19951011, 19950103)), row.names = c(NA, 
-2L), class = "data.frame")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文