5.4 Select columns with select()
It’s not uncommon to get datasets with hundreds or even thousands of variables. In this case, the first challenge is often narrowing in on the variables you’re actually interested in. select() allows you to rapidly zoom in on a useful subset using operations based on the names of the variables.
Does select still work if you are referring to a reactive dataframe? That is the trouble that I seem to be running into-- I'm not sure where I would put a select-- say if I wanted to only include variables 1-3. here is a brief example below!
##outputs
newdata <- reactive({
##make many new variables needed for all of the charts, maps, and plots
##new variables based on user input
##new variables based on user input
Var1 <- as.numeric(input$variable1)
Var2 <- as.numeric(input$varable2)
dataset$'Total'<- Var1 + Var2
newdatadata<-data.frame(dataset$total,
dataset$area,
dataset$x,
dataset$y,
dataset$z,
dataset$a,
dataset$b)
colnames(newdatadata)<- c("Variable 1 ", "Variable 2", "Variable 3", "Variable 4", "Variable 5", "Variable 6", "Variable 7")
})
output$datatable1 <- renderDataTable(newdata(),options = list(
searching = FALSE,
pageLength = 10,
lengthMenu = c(5, 10, 15, 20)))