library(shiny) ui <- shinyUI(fluidPage( radioButtons("soovalik", "Soo valik", c("Poisid"= "m", "Tydrukud" = "n", "K6ik" = "k")), tableOutput("tabel2"), tableOutput("tabel1") )) server <- shinyServer(function(input, output) { lapsed=read.table("http://www.tlu.ee/~jaagup/andmed/muu/5klasskabe.txt", header=TRUE, sep=",") lapsed$kabe=factor(lapsed$kabe, levels=c("ei", "natuke", "jah")) valilapsed <- function(){ if(input$soovalik=="k"){x <- lapsed} else {x <- lapsed[lapsed$sugu==input$soovalik, ]} x } output$tabel2 <- renderTable({ sagedustabel=as.data.frame(table(valilapsed()$kabe)) colnames(sagedustabel)=c("oskus", "sagedus") sagedustabel }) output$tabel1 <- renderTable({valilapsed()}) }) shinyApp(ui = ui, server = server)