R语言 确定特定日期的月份 – months() 函数

R语言 确定特定日期的月份 – months() 函数

R语言中的 month() 函数用于确定作为参数传递给它的特定日期上的月份。

语法: months(date, abbreviate)

参数:

date: 要检查的日期

abbreviate: 缩写月份的布尔值

例1 :

# R program to find the month 
# on a specific date
  
# Specifying the date
date <- as.POSIXlt("2020-06-23")
date
  
# Calling months() function
months(date)
R

输出

[1] "2020-06-23 UTC"
[1] "June"
R

例2 :

# R program to find the month 
# on a specific date
  
# Specifying the date
date <- as.POSIXlt("1994-01-17")
date
  
# Calling months() function
months(date, abbreviate = TRUE)
R

输出

[1] "1994-01-17 UTC"
[1] "Jan"
R

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册