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

Lab 4 - "object 'input' not found" #16

Open
SalvadorW2 opened this issue Jul 9, 2020 · 14 comments
Open

Lab 4 - "object 'input' not found" #16

SalvadorW2 opened this issue Jul 9, 2020 · 14 comments
Labels

Comments

@SalvadorW2
Copy link

SalvadorW2 commented Jul 9, 2020

Hello everyone,

I'm trying to get the following chunk of code to work:

dat.one.team <- filter( .data = Teams,
name == input$my_team )

points( x=dat.one.team$yearID, y=dat.one.team$ave.so,
pch=20,
cex=1.2,
col="goldenrod1",
type="b" )

team.name <- input$my_team

However, I keep getting the following error message:

Error: Problem with filter() input ..1.
x object 'input' not found
i Input ..1 is name == input$my_team.

I've installed Shiny and believe I have configured selectInput correctly:

selectInput(

inputId = "my_team",
label = "Select a team:",
choices = c("New York Yankees",
"Boston Red Sox",
"Oakland Athletics",
"Atlanta Braves",
"Toronto Blue Jays",
"Los Angeles Dodgers",
"Houston Astros",
"Chicago Cubs",
"New York Mets",
"Arizona Diamonbacks"),
selected = "Atlanta Braves"

Does anyone know what the problem could be?

@jamisoncrawford
Copy link
Collaborator

Hm... if object input isn't found, there could be a few reasons for that. Are you using input inside a reactive expression, i.e. render.*({ ... }) ? Have your preceded your code with both library(shiny) and library(dplyr)?

@SalvadorW2
Copy link
Author

Yes, I've done all of those things.

I checked with the library() function and shiny and dplyr are both installed.

I made sure to call them from the library before attempting to run the code.

@jamisoncrawford
Copy link
Collaborator

And they're explicitly in the beginning of your shiny script? The calls to library()?

@BriannaSmithR
Copy link

I'm having the same problem. My code is

team.name <- input$my_team  

dat.one.team <- filter(Teams, 
                       name == input$my_team)

When I run either line, it says "Error: object 'input' not found."

I've also tried

dat.one.team <- filter(Teams, 
                       name == input$my_team)

because I thought that after running my inital code, team.name and input$my_team would be the same, but that code returns "object team.name not found"

I have all the packages loaded, and these are above my renderPlot.

@jamisoncrawford
Copy link
Collaborator

@BriannaSmithR that would likely be the culprit:

I have all the packages loaded, and these are above my renderPlot.

input$ is used in reactive expressions and therefore needs to be in a reactive function like renderPlot(). Try putting it at the very beginning, before your plotting functions, while plotting functions with dat.one.team should be at the very end of renderPlot().

The { } signals to R that something dynamic and responsive to user inputs is occurring within the curly brackets.

@BriannaSmithR
Copy link

I moved

team.name <- input$my_team  

into the renderPlot(), but I'm still getting the "Error: object input no found." I also moved my other code and it isn't working either :(

@jamisoncrawford
Copy link
Collaborator

@BriannaSmithR would you kindly email me your .Rmd file and I can have a look?

@SalvadorW2
Copy link
Author

I've tried what you've said and am having the same problem as Brianna.

Could I do the same?

@jamisoncrawford
Copy link
Collaborator

@SalvadorW2 absolutely!

@jamisoncrawford
Copy link
Collaborator

@SalvadorW2 so the .Rmd script runs perfectly fine and I'm not able to reproduce this error. Couple of notes though:

  1. Only call data(Teams) once, at the beginning - by calling it again after several preprocessing tasks, you restore the Teams dataset to its original state
  2. Your reactive plotting function should go at the very end of the renderPlot() call:
points( x=dat.one.team$yearID, 
        y=dat.one.team$ave.so, 
        pch=20,
        cex=1.2,
        col="goldenrod1",
        type="b" )

It should be the final layer of paint on your visualization, since it's the reactive portion!

Last note is a biggie and so I'm putting it in bold so others will see it:

Everyone:

Running the individual code chunks will throw an error - you need to knit the document in its entirety, since the chunks must communicate with each other simultaneously - running an individual chunk is like seeing if a car will budge when you've taken off half the wheels!

Let me know if this helps!

@SalvadorW2
Copy link
Author

Okay, thank you!

This is helpful.

@jamisoncrawford
Copy link
Collaborator

Sure thing, @SalvadorW2!

@SalvadorW2
Copy link
Author

Thank you,

I have the reactive element working now for the interactive graph.

Sean Waggoner

@jamisoncrawford
Copy link
Collaborator

Great! 🔥

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

No branches or pull requests

3 participants