I am new to Shiny.
When I run the following code I get the message "incorrect number of dimension".
I would like to place a checkboxgroupinput next to every rows of NameGen table, which is a result of a selectInput. Then, if one row is checked, this will go in a new table in the mainPanel.
ui.r
library(shiny)
fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("select","Type",c("C","R","V"),selected=NULL),
uiOutput("choose_row")
),
mainPanel(
tableOutput("result")
)
)
)
server.r
library(shiny)
function(input,output){
data1<-reactive({
setwd("/Users/me/Desktop/DirectoryAlR")
AlData<-read.delim2("AlR.csv",sep=";",stringsAsFactors = FALSE)
NameGen<-NULL
for(i in 1:nrow(AlData)){
if(AlData[i,7]==input$select){
NameGen[i]<-AlData[i,1]
}else{
NameGen[i]<-NA
}
}
NameGen<-NameGen[!is.na(NameGen)]
return(NameGen)
})
output$choose_row<-renderUI({
rn<-rownames(data1())
checkboxGroupInput("box","",rn,selected=NULL)
})
result<-reactive({
data2<-data1()
data2[input$box,,drop=FALSE]
})
output$result<-renderTable(result())
}
Aucun commentaire:
Enregistrer un commentaire