0
votes

Im trying a shiny app which will select a dataset and i am trying a format like dimensions and measures as in tableau. i was able to get all the columns but i need to differentiate numeric and characters datatypes. Here is the code.

'''

server <- function(input, output,session){
data_set <- reactive({
  inFile <- input$InputFile

if (is.null(inFile))
  return(NULL)

data_set<-read.csv(inFile$datapath, header=input$header)

})

observe({
dsnames <- names(data_set())

dim <- dsnames %>% select_if(is.character)
measure <- dsnames %>% select_if(Negate(is.character))

di_option <- list()
di_options[dim] <-dim

me_options <-list()
me_options[measure] <-measure

cb_options <- list()
cb_options[ dsnames] <- dsnames
updateRadioButtons(session, "xaxisGrp",
                   label = "Dimensions",
                   choices = di_options,
                   selected = "")
updateRadioButtons(session, "yaxisGrp",
                         label = "Measures",
                         choices = me_options,
                         selected = "")
})
}

''' Error : Warning: Error in UseMethod: no applicable method for 'tbl_vars' applied to an object of class "NULL"

1

1 Answers

0
votes

Try

di_options <- list(colnames(data_set()[sapply(data_set(),class)=="character"]))

me_options <- list(colnames(data_set()[sapply(data_set(),class)=="numeric"]))