I am developing a shiny app for selecting a pair of players from the below dataset
structure(list(player = c("Samson", "Tausif", "charles", "vinod",
"bhsoley", "sugandhey", "mohit", "ocd", "shankar", "sneha")), class = "data.frame", row.names = c(NA,
-10L))
I am new to r and shiny by reading from multiple sources I am able to develop an app for random selection. the code is as shown below:
ui<-fluidPage(
fileInput('datafile', 'Choose CSV file',
accept=c('csv', 'comma-separated-values','.csv')),
tableOutput('table'),
tableOutput("table1")
)
server<- function(input, output,session) {
dataframe<-reactive({
if (is.null(input$datafile))
return(NULL)
data<-read.csv(input$datafile$datapath)
data
})
dataframe1<-reactive({
if (is.null(input$datafile))
return(NULL)
data1<-read.csv(input$datafile$datapath)
y<-split(sample(data1),rep(1:5,each=2))
df<-data.frame(matrix(unlist(y), nrow=length(y), byrow=T))
df
})
output$table <- renderTable({
dataframe()
})
output$table1 <- renderTable({
dataframe1()
})
}
shinyApp(ui, server)
but each time i run this, it generate the same result however the results are different pair of player in R terminal.
I am looking for a solution where each time I upload a CSV file it generate different player names.