That either works in Python or it doesnt, what can we learn from that about your R code that presumably doesnt work in the way you say it doesnt ?
I'm sorry but you aren't giving me any actionable information with which I can identify an issue and offer a correction.
To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at these resources, to see how to create one for a shiny app