Shiny Wordle Word Journey

[This article was first published on RStudio | Open source & professional software for data science teams on RStudio, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A couple of weeks ago, Winston Chang showed how to create a Wordle app in Shiny in a four-part video series. Go watch the video series to see how he did it! Also, follow along on the first steps to start with Shiny in this tutorial.

In our house, we like puzzles and Wordle. My family noticed while playing the deployed version that there were some words that, while amusing to younger children, were not necessarily what we were expecting to be included. So, with Winston’s support, we decided to take a look at the word list and see if we could make some updates.

I’ve used GitHub and R, so I could start from there. I started with a few steps:

  • Fork the GitHub repository
  • Clone the forked repository to my computer
  • Open the file ‘wordlist.R’ in the RStudio IDE

I was expecting to just modify a word list, basically by parsing and modifying the text file ‘wordlist.R’, putting in a pull request and waiting for it to be merged by Winston to see our changes. But, of course, we didn’t want to wait that long, so we decided to try deploying the Shiny app on our own instead.

First, we wanted to see if we could deploy it as it is without any modifications. I saw that Winston’s was deployed at shinyapps.io, so I too went to shinyapps.io to get set up.

Then, I went back to my RStudio IDE to try to deploy a Shiny app.

I thought I’d try the demo one first to make sure things were working, so I did File -> New File -> Shiny Web App:

RStudio's file menu opning up a Shiny Web App

That brought up a ‘New Shiny Web Application’ window. I named the it ‘shiny-demo’ and clicked ‘Create’.

New Shiny Web App window in RStudio with shiny-demo as the name of the new app

That opened a window with the file ‘app.R’ that told me to click the button ‘Run App’, so I did!

New app.R file letting you know that this is a Shiny app that you can run by clicking Run App

And up opened a Shiny app on Old Faithful!

Old Faithful Geyser Data app showing a histogram of the data and a slider for number of bins

Great, so we had it working locally. We’re basically the coolest now; we did something interactive! Now, could we deploy it to shinyapps.io to share this exciting app with the world?

I went down to the console, first loaded the rsconnect package, and then deployed the app.

library('rsconnect')

(If you forget to load the library, fear not, it won’t work, so you’ll be reminded that you need to do it).

deployApp()
Text shown when deploying an app letting you know the process of being uploaded to shinyapps.io

Then 🎉! There it was at https://tracy-teal.shinyapps.io/shiny-demo/.

Empowered by deploying something, we wanted to go on to deploy the Shiny Wordle app. If we could, it would give us all the power to create whatever word lists we wanted!

I went back to my ‘shiny-wordle’ directory:

  • Set the working directory to that folder using setwd()
  • Open the file ‘app-final.R’ and click ‘Run App’

It opened locally! It was working!

Now to deploy.

I tried deployApp('app-final.R').

That didn’t work. It said Error in deployApp("app-final.R"):

"/Users/tracyteal/Documents/git/fork/shiny-wordle/app-final.R must be a directory, an R Markdown document, or an HTML document."

So, I renamed app-final.R to app.R and ran:

deployApp()

(But I could have done shiny::shinyAppFile("app-final.R")).

Then, it started and took awhile and then success!

There my app was at https://tracy-teal.shinyapps.io/shiny-wordle/.

Blank Shiny Wordle app

Now to try editing the files.

We edited ‘wordlist.R’. The vector words_common contains the set of words that are chosen to be the correct ones. So, rather than a whole list, we put in just a few words that we wanted to have as the answers.

wordlist R file open to show the words common vector of correct words

If you want to add new words that aren’t necessarily actual words, like people’s names, you need to add them to both the words_common and words_all lists.

wordlist R file open to show the words all vector of correct words

Then, we redeployed by running deployApp() again.

We had to hit ‘y’ when it asked if we wanted to ‘Update application currently deployed’.

It ran and then, 🎉! We had our very own Wordle with our very own words!

A customized word list could be a very good gift for family or friends. ☺️

We went on to modify the whole word list, and put in that PR for Winston.

We learned a lot and are excited to try more. We were super excited to get an interactive app up and running so quickly.

So, with the Shiny app, we’ll keep working on the words, and maybe even a version with a different number of letters, as long as we can find a wordlist…

To leave a comment for the author, please follow the link and comment on their blog: RStudio | Open source & professional software for data science teams on RStudio.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)