📦为什么使用 lubridate?

type
status
date
slug
summary
tags
category
icon
password
comment
lubridatetidyverse 中专门处理日期与时间的包,提供了比 base R 更直觉、简洁、强大的 API。
在时间数据处理中,它能大幅减少代码量并提高可读性,非常适合与 dplyrggplot2 等配合使用。

💡 适用场景

  • 快速解析日期时间(如 ymd("2023-10-05")
  • 🧩 提取时间组件(年、月、日、小时等)
  • 🔁 时间运算(加减天数、月份、小时等)
  • 🧹 日期对齐(按月、周、季度聚合)
  • 📊 时间序列可视化与分析(配合 ggplot2、dplyr)

🧠 自动识别日期格式

优势:免去手动指定 %Y-%m-%d 这种复杂格式,解析更直观。

🕒 获取当前时间


📤 提取时间组件

小贴士:在 ggplot2 绘图前,可以用这些函数快速生成分组变量。

🔁 时间加减运算

优势:支持 days()、months()、years() 等直观的加减。

📏 日期对齐(聚合前常用)

常用于按月、按周进行分组统计。

⏱ 计算时间差

选择建议:interval() 更适合做区间运算,difftime() 则适合直接获取差值。
Prev
make_date() & make_datetime():从字段构造时间对象
Next
ISO 8601 国际时间标准
Loading...
Article List
Evan の Logbook
✨ Updates
🎨 Style Guide
🧠 Creative Resources
🗒️ Mind Notes
🧭 Knowbase
📘 SOPs
🩺 Medical Research
🛠️ Tech Chronicles
💰 Fortune Blueprint
📈 R Visionary
📊 Statistics
🖼️ BioVis