Session Ready
Exercise

Choose the data source (server)

When working with radio buttons, sometimes you need to use conditional logic (if-else statements) when accessing the radio button's value in the server. This is necessary when different actions are performed depending on the exact choice, and the chosen value needs to be inspected before deciding how to proceed.

For example, with the radio buttons that select a data source, different code will need to run depending on which choice is selected.

Your next task is to use the appropriate data source in the word cloud function, according to what radio button the user chooses.

Instructions
100 XP
  • Define a reactive variable named data_source to hold the data that will be used for the word cloud (line 28).
  • If the "book" option ("Art of War") is selected, assign the artofwar book as the data source. If the "own" option ("Use your own words") is selected, assign the textarea's value as the data source. If the "file" option ("Upload a file") is selected, assign the text from a user-submitted file as the data source (lines 33 through 36).
  • Use the data_source() reactive variable as the data argument to the word cloud function (line 51).