Have dataset in which want to show columns which is depends on user input
```
##ui.r
library(shiny)
shinyUI(
fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("thisMenu", label="Mode", choices=c("2","3","4"), selected=1)
),
mainPanel(
tableOutput("fileData")
)
)
)
)
```
```
##server.r
library(shiny)
library(dplyr)
shinyServer(function(input, output) {
output$fileData <- renderTable({
fileData <- read.csv("app-data.csv")
sCols <- as.numeric(input$thisMenu)
fileData <- select(fileData, 1:sCols)
fileData[,2:sCols] <- prettyNum(fileData[,2:sCols], width=15, justify="right", big.mark=",")
fileData <<- fileData
fileData
}, align='eval(myAlign())')
myAlign <- function(x) {
sCols <- as.numeric(input$thisMenu)
align <- rep("r",sCols-1)
align <- paste("ll",paste(align, collapse=""), sep="")
#align <<- align
return(align)
}
})
```
Notice the use of function in "align" of renderTable.
This works the first time but once the selectInput value changes the align gives a problem.
Sample data-set provided below
```
### fileData
LeftColName RightColumn.1 RightColumn.2 RightColumn.3 RightColumn.4
1 Row 1 1,00,000 2,00,000 3,00,000 4,00,000
2 Row 2 1,00,000 2,00,000 3,00,000 4,00,000
3 Row 3 1,00,000 2,00,000 3,00,000 4,00,000
4 Row 4 1,00,000 2,00,000 3,00,000 4,00,000
5 Row 5 1,00,000 2,00,000 3,00,000 4,00,000
6 Row 6 1,00,000 2,00,000 3,00,000 4,00,000
7 Row 7 1,00,000 2,00,000 3,00,000 4,00,000
8 Row 8 1,00,000 2,00,000 3,00,000 4,00,000
9 Row 9 1,00,000 2,00,000 3,00,000 4,00,000
```
Any help on this will be appreciated.