DS4PS / cpp-529-fall-2020

http://ds4ps.org/cpp-529-fall-2020/
0 stars 0 forks source link

Character(0) from histogram tabs #36

Open ekmcintyre opened 3 years ago

ekmcintyre commented 3 years ago

I made sure to include the as.numeric argument in my code for variable distributions

x <- get_variable_x() %>% unlist() %>% as.numeric()

and now keep getting an error saying character (0). Does this have to do with the variables I have selected?

image

lecy commented 3 years ago

It looks like you are not referencing the variable correctly.

What is your widget code, especially the input ID?

Does the input$id reference match with what is in the function get_variable_x()?

Here id would be replaced by whatever you named your widget. For example, it was called input$demographics in the demo code:

radioButtons( inputId="demographics", 
              label = h3("Census Variables"),
              # choices = these.variables, 
              choiceNames=temp.names,
              choiceValues=these.variables,
              selected="pnhwht12")

Your input$id slot will store the currently selected variable name.

ekmcintyre commented 3 years ago

My code for the input is this

radioButtons( inputId="demographics", 
              label = h3("Census Variables"),
              choiceNames=mean.labels,
              choiceValues=these.variables,
              selected="Percent White")

And my code in the output is this

mutate( q = ntile( get(input$demographics), 10 )

lecy commented 3 years ago

Your selected= argument should reference a variable name, not a label.

ekmcintyre commented 3 years ago

Okay that fixed it.

lecy commented 3 years ago

👍