连续小波变换 - 日期未以正确格式显示
Continuous Wavelet Transform - Date Not Shown in Proper Format
我正在使用 R 中的“biwavelet”包执行小波分析。我是运行以下代码:
library(foreign)
library(survey)
library(dplyr)
library(Rwave)
library(waveslim)
library(biwavelet)
library(xts)
library(labelled)
library(zoo)
date =c("2020-02-13", "2020-02-14", "2020-02-15", "2020-02-16", "2020-02-17", "2020-02-18", "2020-02-19", "2020-02-20", "2020-02-21", "2020-02-22", "2020-02-23", "2020-02-24", "2020-02-25", "2020-02-26", "2020-02-27", "2020-02-28", "2020-02-29", "2020-03-01", "2020-03-02", "2020-03-03", "2020-03-04", "2020-03-05", "2020-03-06", "2020-03-07", "2020-03-08", "2020-03-09", "2020-03-10", "2020-03-11", "2020-03-12", "2020-03-13")
rdate = as.Date(date)
date <- as.Date(date, format = "%Y-%m-%d")
date
class(date)
var = c(-0.032297026, -0.037759505, -0.043272924, -0.048837278, -0.054452576, -0.060118809, -0.065835983, -0.071604095, -0.077423148, -0.083293147, -0.089214072, -0.095185943, -0.101208754, -0.107282504, -0.113407195, -0.119582824, -0.125809386, -0.125806898, -0.132149309, -0.138584509, -0.145112529, -0.151733354, -0.158446968, -0.165253401, -0.172152638, -0.179144681, -0.186229542, -0.193407193, -0.200677648, -0.208040923)
data = data.frame(date, var)
View(data)
X <- as.xts(data[,-1], order.by = date)
attach(data)
ABC <- cbind(date, var)
wt.t1=plot(wt(ABC))
生成的绘图未以正确的格式显示日期,而是显示为 18305、18310 等。我如何以正确的日期格式显示日期。
问题出在脚本的倒数第二行:ABC <- cbind(date, var)
。 cbind()
函数输出一个矩阵,两列不能有单独的 class。如果您使用 ABC <- data.frame(date, var)
,日期 class 不会丢失。
虽然图片还是不太好看,因为默认格式是“%Y”,所以所有日期都显示为“2020”。为了获得更好的情节,请选择一种日期格式并使用它,例如
plot(wt(ABC), form = "%b-%d")
这给出了
我正在使用 R 中的“biwavelet”包执行小波分析。我是运行以下代码:
library(foreign)
library(survey)
library(dplyr)
library(Rwave)
library(waveslim)
library(biwavelet)
library(xts)
library(labelled)
library(zoo)
date =c("2020-02-13", "2020-02-14", "2020-02-15", "2020-02-16", "2020-02-17", "2020-02-18", "2020-02-19", "2020-02-20", "2020-02-21", "2020-02-22", "2020-02-23", "2020-02-24", "2020-02-25", "2020-02-26", "2020-02-27", "2020-02-28", "2020-02-29", "2020-03-01", "2020-03-02", "2020-03-03", "2020-03-04", "2020-03-05", "2020-03-06", "2020-03-07", "2020-03-08", "2020-03-09", "2020-03-10", "2020-03-11", "2020-03-12", "2020-03-13")
rdate = as.Date(date)
date <- as.Date(date, format = "%Y-%m-%d")
date
class(date)
var = c(-0.032297026, -0.037759505, -0.043272924, -0.048837278, -0.054452576, -0.060118809, -0.065835983, -0.071604095, -0.077423148, -0.083293147, -0.089214072, -0.095185943, -0.101208754, -0.107282504, -0.113407195, -0.119582824, -0.125809386, -0.125806898, -0.132149309, -0.138584509, -0.145112529, -0.151733354, -0.158446968, -0.165253401, -0.172152638, -0.179144681, -0.186229542, -0.193407193, -0.200677648, -0.208040923)
data = data.frame(date, var)
View(data)
X <- as.xts(data[,-1], order.by = date)
attach(data)
ABC <- cbind(date, var)
wt.t1=plot(wt(ABC))
生成的绘图未以正确的格式显示日期,而是显示为 18305、18310 等。我如何以正确的日期格式显示日期。
问题出在脚本的倒数第二行:ABC <- cbind(date, var)
。 cbind()
函数输出一个矩阵,两列不能有单独的 class。如果您使用 ABC <- data.frame(date, var)
,日期 class 不会丢失。
虽然图片还是不太好看,因为默认格式是“%Y”,所以所有日期都显示为“2020”。为了获得更好的情节,请选择一种日期格式并使用它,例如
plot(wt(ABC), form = "%b-%d")
这给出了