闪亮应用程序中的R addTA函数
我想创建一个闪亮的应用程序来显示chartseries绘图。但是,它没有显示addTA图。我想在chartseries函数之外执行addTA函数,因为我想将它们放入选项中,在我的代码下面: ui.R: 服务器.R闪亮应用程序中的R addTA函数,r,function,plot,shiny,quantmod,R,Function,Plot,Shiny,Quantmod,我想创建一个闪亮的应用程序来显示chartseries绘图。但是,它没有显示addTA图。我想在chartseries函数之外执行addTA函数,因为我想将它们放入选项中,在我的代码下面: ui.R: 服务器.R library(shiny) library(quantmod) shinyServer(function(input, output) { output$text3 <- renderText({ paste("you have chosen a stock ",
library(shiny)
library(quantmod)
shinyServer(function(input, output) {
output$text3 <- renderText({
paste("you have chosen a stock ", input$symb)
})
dataInput <- reactive({
getSymbols(input$symb, src = "yahoo",
auto.assign = FALSE, periodicity = input$period)
})
output$plot <- renderPlot({
chartSeries(dataInput(), theme = chartTheme("white"),
up.col = "green", dn.col = "red",
TA = NULL, name = input$symb, subset = input$subset)
addTA(SMA(Cl(na.omit(dataInput())),n=2), col="red", on = 1)
addTA(SMA(Cl(na.omit(dataInput())),n=19), col="blue", on = 1)
})
})
库(闪亮)
图书馆(quantmod)
shinyServer(功能(输入、输出){
输出$text3用print(.)
包装您的quantmod图表函数调用chartSeries/chart_Series、addTA/add_TA、addRSI
等,以确保它们在闪亮的应用程序中绘制:
shinyServer(function(input, output) {
output$text3 <- renderText({
paste("you have chosen a stock ", input$symb)
})
dataInput <- reactive({
getSymbols(input$symb, src = "yahoo",
auto.assign = FALSE, periodicity = input$period)
})
output$plot <- renderPlot({
print(chartSeries(dataInput(), theme = chartTheme("white"),
up.col = "green", dn.col = "red",
TA = NULL, name = input$symb, subset = input$subset))
print(addTA(SMA(Cl(na.omit(dataInput())),n=2), col="red", on = 1))
print(addTA(SMA(Cl(na.omit(dataInput())),n=19), col="blue", on = 1))
})
})
shinyServer(功能(输入、输出){
输出$text3用print(.)
包装您的quantmod图表函数调用chartSeries/chart_Series、addTA/add_TA、addRSI
等,以确保它们在闪亮的应用程序中绘制:
shinyServer(function(input, output) {
output$text3 <- renderText({
paste("you have chosen a stock ", input$symb)
})
dataInput <- reactive({
getSymbols(input$symb, src = "yahoo",
auto.assign = FALSE, periodicity = input$period)
})
output$plot <- renderPlot({
print(chartSeries(dataInput(), theme = chartTheme("white"),
up.col = "green", dn.col = "red",
TA = NULL, name = input$symb, subset = input$subset))
print(addTA(SMA(Cl(na.omit(dataInput())),n=2), col="red", on = 1))
print(addTA(SMA(Cl(na.omit(dataInput())),n=19), col="blue", on = 1))
})
})
shinyServer(功能(输入、输出){
输出$text3我可以再问一个问题吗?如果我在checkboxGroupInput中设置了这些指标,我单击时如何显示这些指标?我不知道如何将输入$indicator放入addTA函数中。@Peter Chung当然,请给出一些示例代码,我会看一看(或者其他人可能会看)。这可能是另一个问题,但我可以再问一个问题吗?如果我在checkboxGroupInput中设置了这些指标,我单击时如何显示这些指标?我不知道如何将input$指标放入addTA函数中。@Peter Chung当然,请给出一些示例代码,我会看一看(或者其他人可能会看).但这可能是另一个问题