[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
使用者(已经有用R 做过不少作品)
[问题叙述]:
想尝试将ui端输入的文字带入函式中,按下执行钮后出现错误
Warning: Error in [: incorrect number of dimensions
想请问出现此错误是因为server 与ui没有对应到,或是带入函式方法错误
[程式范例]:
shinyServer(
function(input, output,session) {
library(rsconnect)
library(tseries)
library(quantmod)
library(forecast)
library(car)
library(haven)
observeEvent(
input$goButton,{
index2<-as.character( input$index1)
getSymbols(c(index2),from = "1900-01-05")
index.open<-data.frame(as.numeric(c(index2)[,1]))
index.open.year<-data.frame(tail(index.open,365))
colnames(index1.open.year)="OP.value"
output$year.plot<-renderPlot(plot(index.open.year,main = "index plot"))
output$value<-renderTable(data.frame(tail(index.open.year,5)))
})})
library(shiny)
library(rsconnect)
shinyUI(fluidPage(
titlePanel("index plot and table"),
mainPanel(
textInput( "index1",label = "index") ,
actionButton("goButton", "Go!"),
plotOutput("year.plot"),
tableOutput("value")
)))
[环境叙述]:
R 3.5 shiny
[关键字]:
shiny ui 输入