0
基本上,我希望用户提供一个值向量:X = 1,2,3和Y = 2.3,4.5,6.7在闪亮的界面中从闪亮输入创建多行数据帧
并得到这样的一个表:
X Y
1 2.3
2 4.5
3 6.7
不过,我只得到了价值一排:
X Y
1,2,3 2.3,4.5,6.7
服务器
library("shiny")
shinyServer(
function(input,output,session){
Data = reactive({
if (input$submit > 0) {
df <- data.frame(x=input$x,y=input$y)
return(list(df=df))
}
})
output$table <- renderTable({
if (is.null(Data())) {return()}
print(Data()$df)
}, 'include.rownames' = FALSE
, 'include.colnames' = TRUE
, 'sanitize.text.function' = function(x){x}
)
})
UI
library("shiny")
shinyUI(
pageWithSidebar(
headerPanel("textInput Demo")
,
sidebarPanel(
wellPanel(
textInput('x', "enter X value here","")
,
textInput('y', "enter Y value here","")
,
actionButton("submit","Submit")
)
)
,
mainPanel(uiOutput('table'))
))
如何解决这个问题的任何想法?
在此先感谢了很多,
您只从'textInput'获得一个字符串。你需要将它们转换为数字。 –