Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting Input & Output in Dashboard #27

Open
SalvadorW2 opened this issue Jul 30, 2020 · 6 comments
Open

Connecting Input & Output in Dashboard #27

SalvadorW2 opened this issue Jul 30, 2020 · 6 comments

Comments

@SalvadorW2
Copy link

Hello, I'm having trouble connecting my input and output in the dashboard.

Here is my input:

selectInput(inputId = "driver.1.alcohol",
label = h4("Driver 1: Influence of Alcohol"),
choices = c("No Apparent Influence","Alcohol"),
selected = c("No Apparent Influence"))

selectInput(inputId = "driver.2.alcohol",
label = h4("Driver 2: Influence of Alcohol"),
choices = c("No Apparent Influence","Alcohol"),
selected = c("No Apparent Influence"))

selectInput(inputId = "driver.1.drugs",
label = h4("Driver 1: Influence of Drugs"),
choices = c("No Apparent Influence","Drugs"),
selected = c("No Apparent Influence"))

selectInput(inputId = "driver.2.drugs",
label = h4("Driver 2: Influence of Drugs"),
choices = c("No Apparent Influence","Drugs"),
selected = c("No Apparent Influence"))

Here is my output:

renderLeaflet({

d2 <- dat %>%
filter(AlcoholUse_Drv1 %in% input$driver.1.alcohol,
AlcoholUse_Drv2 %in% input$driver.2.alcohol,
DrugUse_Drv1 %>% input$driver.1.drugs,
DrugUse_Drv2 %>% input$driver.2.drugs)

Any help would be appreciated, thank you.

@SalvadorW2
Copy link
Author

Alright, I've corrected the output as follows:

DrugUse_Drv1 %in% input$driver.1.drugs,
DrugUse_Drv2 %in% input$driver.2.drugs

@jamisoncrawford
Copy link
Collaborator

Hi Sean,

Are you intending to use the original variables or the new variables d1.substance and d2.substance? If the latter:

Did you implement the code in issue #24 ? These variables will be troublesome without them.

If the former, what are you expecting to happen and what is happening instead? What error message are you getting, if any? What is displayed? Do the input widgets function and does the output draw a map?

Also, is there a reason you're using radio buttons and not checkboxGroupInput() for multiple options? That might make for a cleaner interface.

For radio buttons, == is better than %in% since it's a forced choice. %in% is best for check boxes and multiple values.

Another method for trouble shooting is renaming d2 in your output code to something new, like d9. You'll have to change it multiple times in the chunk. Maybe I'm superstitious but that has helped me in the past.

@SalvadorW2
Copy link
Author

I did implement the code in #24.

I used the former and now it seems to be working.

Thank you

@jamisoncrawford
Copy link
Collaborator

You're welcome! What ended up fixing it? Just for my knowledge and future reference?

@SalvadorW2
Copy link
Author

I just made the variables exactly equal the inputs.

@jamisoncrawford
Copy link
Collaborator

jamisoncrawford commented Aug 1, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants