There is nothing wrong with the code you have shared so the problem must lay in the interaction of the code with your specific data (Key_Risks) but you have not shared a sample with us so, 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