Below are my codes trying to plot something using plotly
. After running the codes, the graph is not displayed in the Viewer
pane. Check screenshot. Any clue?
set.seed(1234)
ts_non_trend = ts(runif(200, 5,5.2), start = c(2007,1), frequency = 12)
ts_linear_trend_p = ts_non_trend + 1:length(ts_non_trend) / (0.5 * length(ts_non_trend))
ts_linear_trend_n = ts_non_trend - 1:length(ts_non_trend) / (0.5 * length(ts_non_trend))
ts_exp_trend = ts_non_trend + exp((1:length(ts_non_trend)-1 ) / (0.5 * length(ts_non_trend))) - 1
library(xts)
merged_series = merge(Baseline_No_Trend = as.xts(ts_non_trend),
Positive_Linear_Trend = as.xts(ts_linear_trend_p),
Negative_Linear_Trend = as.xts(ts_linear_trend_n),
Exponential_Trend = as.xts(ts_exp_trend))
# plot(merged_series, main = "Different Types of Trends", ylab = "The Values of the Series", xlab = "Year")
library(TSstudio); library(plotly)
ts_plot(merged_series, type = "single", Xgrid = TRUE, Ygrid = TRUE,
title = "Different Types of Trends",
Ytitle = "The Values of the Series", Xtitle = "Year") %>%
layout (legend = list(x = 0.1, y = 0.9))