如何在R中把时间序列 "POSIXct "转换为Date格式?

问题描述 投票:0回答:1

我有月度时间序列数据在excel文件中,它是 "POSIXct""POSIXt "类。它是 "POSIXct""POSIXt "类。我想把这些数据转换成日期格式="%Y%m"。我想增加一个月的方式,开始值是从95年2月

    Date max    min     mean     PPT             Q
Jan-95  280.7   275.2   276.3   54.97001368 77.22654839
Feb-95  285.5   284.7   290.55  85.56014243 65.10167857
Mar-95  291.3   296.3   307.95  21.73403927 62.66664516
Apr-95  295.4    305    321     46.40860902 80.3805
May-95  302.3   314.6   335.4   101.350745  123.6887742
Jun-95  306.6   321.3   345.45  51.36630928 491.1493667
Jul-95  309.9   327.5   354.75  29.5892797  905.7528065
Aug-95  309.5   327.2   354.3   56.71881787 726.2029355
Sep-95  305.5   318     340.5   55.58525046 321.7907333
Oct-95  298     305.3   321.45  24.09003613 171.9048065
Nov-95  293.1   292     301.5   31.49880152 114.4126667
Dec-95  282.9   280.5   284.25  59.8837784  88.75790323

dataset <- read_excel("Gilgit.xlsx")
colnames(pr1)<-c("Date", "Q", "SEAS_1d")
pr1$Date<-pr1$Date+1 
lubridate zoo
1个回答
0
投票

基本上,我有每月的数据,当我打开我的数据在R.它是在以下格式。

pr1 <- read_excel("Gilgit.xlsx", sheet = 1)
colnames(pr1)<-c("Date", "Q", "SEAS_1d")
pr1$Date<-pr1$Date+1 
db1<-merge(db, pr1, by=c("Date"))

添加日期后,它看起来像。在这里输入图像描述

© www.soinside.com 2019 - 2024. All rights reserved.