【862】as.Date in R programming
ref: R语言——日期时间处理
ref: as.Date: Date Conversion Functions to and from Character
ref: Date Formats in R
as.Date()
it can change a normal string into a date format.
format()
It can extract the specific date format from a date string.
Example:
> d = "2020-02-21" > format(as.Date(d), format="%B, %Y") [1] "February, 2020" > format(as.Date(d), format="%d %B, %Y") [1] "21 February, 2020" > format(as.Date(d), format="%d %B, %Y, %A") [1] "21 February, 2020, Friday"
Date Formats
Conversion specification | Description | Example |
%a | Abbreviated weekday | Sun, Thu |
%A | Full weekday | Sunday, Thursday |
%b or %h | Abbreviated month | May, Jul |
%B | Full month | May, July |
%d | Day of the month 01-31 |
27, 07 |
%j | Day of the year 001-366 |
148, 188 |
%m | Month 01-12 |
05, 07 |
%U | Week 01-53 with Sunday as first day of the week |
22, 27 |
%w | Weekday 0-6 Sunday is 0 |
0, 4 |
%W | Week 00-53 with Monday as first day of the week |
21, 27 |
%x | Date, locale-specific | |
%y | Year without century 00-99 |
84, 05 |
%Y | Year with century on input: 00 to 68 prefixed by 20 69 to 99 prefixed by 19 |
1984, 2005 |
%C | Century | 19, 20 |
%D | Date formatted %m/%d/%y | 05/27/84, 07/07/05 |
%u | Weekday 1-7 Monday is 1 |
7, 4 |
%n | Newline on output or Arbitrary whitespace on input |
|
%t | Tab on output or Arbitrary whitespace on input |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2021-07-20 【616】安装 GDAL(rasterio)