[問題] 如何使用shiny textInput()
[問題類型]:
程式諮詢(我想用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 輸入
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.96.98.58
※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1544533545.A.FC3.html
→
12/12 08:07,
6年前
, 1F
12/12 08:07, 1F
→
12/12 08:37,
6年前
, 2F
12/12 08:37, 2F
→
12/12 08:37,
6年前
, 3F
12/12 08:37, 3F
→
12/12 12:43,
6年前
, 4F
12/12 12:43, 4F
感謝!
因為第一次試按鈕以及文字輸入
後來使用
index3<-getSymbols(c(index2),from = "1900-01-05",auto.assign = FALSE)
index.open<-data.frame(index3[,1]))
就成功了!
※ 編輯: asdfrtg (175.96.98.58), 12/14/2018 00:28:03
推
01/23 22:58,
7年前
, 5F
01/23 22:58, 5F
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章