Hi @joyce1! Welcome!
It's not possible for a helper to run this code as-is, because it depends on data files that the helper won't have available. I'm afraid that makes it difficult for anybody to understand exactly what your problem is.
The code also isn't formatted correctly, which makes it not-very-fun to read (especially the case for shiny code, where there's lots of indentation!). It looks like maybe when you pasted the code in, you formatted it with the little double-quote button (which formats the selected text as a block quote)? What you wanted to use was the little </>
button (which formats the selected text as code). Can you please edit your original post to try the paste again, this time with the correct formatting?
Even better, take a look at our Shiny Reprex and Debugging Guide, which talks about how to make a small reproducible example that shows the problem you're having. Supplying a reproducible example will make it much more likely that someone will be able to help!
This seems like a somewhat separate question. We encourage people to ask separate questions in separate topics. Once you get the basic app working, if you still aren't sure how to do this part, that would be a good time to start a new topic (linking to this one), with this follow-up question.