Hi all,
Hope everyone is safe and well.
I have a guessing game that I coded in R. Basically, I have a dataframe with all the states and their capitals. I wrote an R code that displays a random capital and asks user to guess the state. It maintains a count if the user is correct, stops the game at first wrong answer and displays the final count of correct answer. Here is the R code:
count = 0
while (userstate==dataframe_state)
{
randnum = sample.int(551, 1)
x = type.convert(randnum,'integer')
y = df[x,"capital"]
userstate = readline("which state does this belong to:")
dataframe_state = df[x,"state"]
count = count+1
}
paste0("Your Score is:",count)
I want to replicate this in Shiny but am having trouble wrapping my head around how do I loop through the user inputs in Shiny. Also, overall what is the best way to replicate the guessing game in Shiny
All ideas are welcome. I am new to the tool.
Thanks,
NV