Trying to create a data frame like below;
X Y
20 30
Using textInput to create data frame.
But values entered in text area are not assigning properly to data frame.
Could you please help me?
ui.R
library(shiny)
shinyUI(pageWithSidebar(
headerPanel( "", ""),
sidebarPanel(
wellPanel(
textInput('datavalues', "variable values",""),
actionButton("submit","Apply")
)
),
mainPanel(
verbatimTextOutput('datatable')
)
))
server.R
library(shiny)
shinyServer(function(input,output,session){
data1= reactive({
if(input$submit!=0){
isolate({
data.frame(paste(input$datavalues))
})
}
})
output$datatable<-renderPrint(function(){
if(!is.null(data1())){
d<-data1()
print(d)
}
})
})
I would recommend using the matrixInput function of the shinyIncubator package. I have made a demo here: https://gist.github.com/anonymous/8207166. You can run it from RStudio with:
But to answer your question based on your code, below is a modification that works. Note that the function renderTable() takes arguments that allow you to control the display of the data.frame. The advantage of using the matrixInput function is that you can make the size of your dataframe reactive, whereas below it is hard-coded as a 2 variable dataframe.
ui.R
server.R