r - Plot LOESS (STL) decomposition using Ggvis -


i want able plot 3 different elements of seasonal trend decomposition using loess (stl) ggvis.

however, recive error:

error: data_frames can contain 1d atomic vectors , lists 

i using nottem data set.

# seasonal trend decomposition using loess (stl) ggvis # load nottem data set library(datasets) nottem <- nottem  # decompose using stl() nottem.stl = stl(nottem, s.window="periodic")  # plot decomposition plot(nottem.stl) 

now, information interested in. in order make plot can play around transform data frame using xts-package. far good.

# transform nottem.stl data.frame library(xts) df.nottem.stl <- as.data.frame(as.xts(nottem.stl$time.series))  # add date data.frame df.nottem.stl$date <- data.frame(time = seq(as.date("1920-01-01"), = ("months"), length =240))  # glimpse data glimpse(df.nottem.stl)  # plot simple line of trend plot(df.nottem.stl$date, df.nottem.stl$trend, type = "o") 

enter image description here

this pretty plot want. however, want able use shiny , therefore ggvis preferable.

# plot ggvis df.nottem.stl%>%   ggvis(~date, ~trend)%>%   layer_lines() 

this error.

any hints on might go wrong?

first of df.nottem.stl data.frame contains date data.frame, should using date$time column. using layer_paths function instead of layer_lines make work. find layer_paths working better layer_lines:

so work:

library(ggvis) df.nottem.stl%>%   ggvis(~date$time, ~trend)%>%   #for points   layer_points() %>%    #for lines   layer_paths() 

output:

enter image description here


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -