Animal Crossing Tinder with {shinysense}

Screenshot of the ACNH Popularity Contest app showing a villager that the user is being asked to swipe left to dislike or right to like.

Lily <3 4eva

tl;dr

The villagers of Animal Crossing: New Horizons are taking part in a popularity contest and you’re the judge.

I made an R Shiny app where you swipe right if you like a randomly-presented villager and left if you dislike them.

Visit the app here and help decide the most popular villager! You can also visit the source code.

Tidy Tuesday

Tidy Tuesday is an open event for the R community. The organisers provide a data set and participants submit their take on wrangling and presenting the data, usually via Twitter with the hashtag #tidytuesday.

A recent data set (week 19) via VillagerDB includes information about villager non-player characters from the wildly popular Animal Crossing: New Horizons game for the Nintendo Switch. A similar set of data was also uploaded to Kaggle.

I couldn’t resist, having recently written about learning R6 object-oriented programming with an Animal Crossing example.

This was also a good chance to learn more about two packages in particular: {shinysense} and {googlesheets4}.

{shinysense}

Nick Strayer‘s {shinysense} package lets Shiny ’sense the world around it’, with modules for touch, vision, hearing and motion.

I wanted to try out shinyswipr, which presents a user with a ‘card’ that they can swipe. The direction of swiping can be used to indicate something, like a preference. After swiping, the card content can be updated.

You can read Nick’s blog post about its inception.

{googlesheets4}

In Nick’s shinyswipr example, he presents back to the user their swipe history, but how can we record the information from all users and return the collated results?

There’s a number of ways to do persistent storing with Shiny, but a relatively simple one is to write the data to Google Sheets and read the entire sheet back into the app.

The {googlesheets4} package by Jenny Bryan helps you do exactly that, with functions like sheet_append() and read_sheet().

The ACNH Popularity Contest

There’s a lot of articles online about favourite villagers, but they aren’t very democratic. They tend to cite characters like Raymond, Beau, Marshal, Judy and Audie.

It’s time to let the people speak.

How to use

If you visit the app, or look at the image at the top of this post, you’ll see that the user is presented with a card containing a randomly-selected villager and some details (name, species, personality and hobby).

You can move the card to the right to indicate you like the character, or to the left if you dislike them. On mobile you can swipe left or right with your finger. On desktop you can click and drag the card.

The swipe event results in the information being written to a Google Sheet and triggers the entirety of the updated data set to be read back to the app. It’s then wrangled lightly and the information is presented as a table of the current top 10 villagers by ‘like’ count. Finally, a new random villager is presented.

This is obviously a bit of fun and definitely not polished. Do let me know of any bugs that you find, though. I’m aware that mobiles may not display the fonts correctly, for example.

Data and hosting

No data about the user is stored. The app records only the date-time, the villager name and the swipe direction.

The app is hosted for free on shinyapps.io, so there’s a limited number of uptime hours it can use per month.

Results

I hope that enough people cast a vote to make the results interesting… but there’s nearly 400 villagers, so that seems unlikely!