我想forecast使用dygraphs. 该文档建议使用以下方法进行实际预测:
hw <- HoltWinters(ldeaths)
p <- predict(hw, n.ahead = 36, prediction.interval = TRUE)
all <- cbind(ldeaths, p)
dygraph(all, "Deaths from Lung Disease (UK)") %>%
dySeries("ldeaths", label = "Actual") %>%
dySeries(c("p.lwr", "p.fit", "p.upr"), label = "Predicted")
Run Code Online (Sandbox Code Playgroud)
绘制对象的有趣之处all在于它的类:
> class(all)
[1] "mts" "ts" "matrix"
> is.mts(all)
[1] TRUE
> is.ts(all)
[1] TRUE
> is.matrix(all)
[1] TRUE
Run Code Online (Sandbox Code Playgroud)
str提供有关对象的更多信息all:
> str(all)
Time-Series [1:108, 1:4] from 1974 to 1983: 3035 2552 2704 …Run Code Online (Sandbox Code Playgroud) 我想存储以下代码的输出。我尝试了列表,数据框和向量,但无法存储。
Model<-lda( y ~ Trend+Class+F1+F4+ATR+macd_signal+macd1+F5 ,data=x)
> Model
Call:
lda(y ~ Trend + Class + F1 + F4 + ATR + macd_signal + macd1 +
F5, data = x)
Prior probabilities of groups:
LOSS PROFIT
0.4981818 0.5018182
Group means:
TrendBull ClassUP F1 F4 ATR macd_signal macd1 F5
LOSS 0.5450122 0.3990268 1480.451 1481.672 11.64657 -0.0005850151 0.01542818 1478.567
PROFIT 0.5000000 0.4082126 1487.280 1486.707 12.25799 -0.0304256947 -0.03845741 1489.620
Coefficients of linear discriminants:
LD1
TrendBull -0.033267160
ClassUP 0.151291378
F1 -0.003215276
F4 -0.042431558
ATR 0.082615338 …Run Code Online (Sandbox Code Playgroud) 我希望能够根据类别数量的变化在我的R markdown文件中生成选项卡集。我写了以下示例.Rmd:
---
title: "Dynamic Tabsets"
output: html_document
---
# Graph Tabs {.tabset .tabset-pills}
```{r, results='asis'}
headers <- list('graph 1', 'graph 2', 'graph 3')
for (h in headers){
cat("##", h, '<br>', '\n')
cat('This is text for', h, '<br>')
plot.new()
plot(diffinv(rnorm(100)), type = 'o', main = h)
cat('\n', '<br>', '\n')
}
```
Run Code Online (Sandbox Code Playgroud)
我希望它创建一个包含3个选项卡的选项卡集,每个选项卡均包含一个图形。目前,当我编织文件时,它不起作用:
有什么办法可以克服这个问题?理想情况下,我希望可以动态确定R markdown输出中包含的内容。