The code snippet run here shows the prediction table of species of irises. A classification tree (rpart
) was trained (using caret
) on the iris dataset and the test data was then predicted.
### A reactive expression executes when the inputs change.
outs <- reactive({interact(input$train_percent, input$method)})
output$table.out <- renderTable({outs()$out.table})
##
## pred setosa versicolor virginica
## setosa 35 0 0
## versicolor 0 35 5
## virginica 0 0 30
The interact()
function actually calls several other functions which ultimately output the table above.
(The entire code won't fit on this slide, but it was processed by Rstudio when the slidify document was knitted!)
Here's the complete code.