๐ก What is reactivity and what does it have to do with a carrier pigeon? ๐ฆ
To better understand how a #ShinyApp works, it's good to understand what's behind reactivity.
To describe it, I love the image of a carrier pigeon ๐ฆ (I picked up this idea when reading a post by @StatGarrett - so all credits go to him and all errors are mine โจ)
@StatGarrett What reactivity does is "a magic trick [that] creates the illusion that one thing is happening, when in fact something else is going on" (shiny.rstudio.com/articles/underโฆ).
@StatGarrett Your ShinyApp only re-runs those parts where it is necessary. But what does this have to do with a carrier pigeon? Have a look at the GIF:
@StatGarrett It shows your ShinyApp with the UI ๐ค (bottom right) and the server ๐ง (top right). The user (bottom left) asks for something ๐๐ผโโ๏ธ
@StatGarrett In the first round, the user asks for "Rwanda" and - after checking, the ShinyApp does not re-run because it already shows Rwanda. โ
@StatGarrett In the next round, the user asks for "Rwanda" and "Angola" - the ShinyApp evaluates and initiates a re-run to update the requested selection. Here comes the carrier pigeon ๐ฆ It starts sending the signal to update to the server.
@StatGarrett Once it has delivered the message, it comes back to where it started and waits until it gets a new message to deliver (just like a carrier pigeon ๐). So, there is only some kind of action (such as updating the plot) if necessary.
@StatGarrett This was a simple wrap-up of Garrett's post - if you want to know more about reactive values and observers, have a look here: shiny.rstudio.com/articles/underโฆ ๐ฉ๐ผโ๐ป
โข โข โข
Missing some Tweet in this thread? You can try to
force a refresh
And in my last Twitter thread, I wanted to talk with you about some powerful approaches in #NLP and how we can use both #rstats and #python to unleash them ๐ช
One possible downside when using the bag of words approach described before is that you often cannot fully take the structure of the language into account (n-grams are one way, but they are often limited).
You also often need many data to successfully train your model - which can be time-consuming and labor intensive. An alternative is to use a pre-trained model. And here comes @Google's famous deep learning model: BERT.
The curation week is almost over and I would like to thank everyone for joining the discussions this week! Itโs been a blast ๐ฅณ
If you enjoyed this week, feel free to reach out on Twitter (@cosima_meyer) or GitHub (github.com/cosimameyer/) โจ
@cosima_meyer I feel very honored that I had the chance to talk with you about the things I enjoy doing and I cannot wait to learn more from the upcoming curators - the lineup looks amazing! ๐
@cosima_meyer If you missed a Twitter thread this week, head over to @pilizalde's amazing thread where she collected all of them (I love the GitHub emoji ๐บ)
๐ฉ๐ผโ๐ป How do you set up your own #ShinyApp?
It's easy in #rstats! Start a new #Rproject and select "Shiny Application". It will create a project with an "app.R" file for you โจ
Once it's open, you can replace the code that is already in the "app.R" file with this code snippet below๐ It does all the magic and shows how you can build a simple #ShinyApp ๐ฎ
You have checkboxes on the left side that let you choose countries (it's the ISO3 abbreviation, so "RWA" stands for Rwanda) and, depending on what you selected, your #ShinyApp will show a (non-realistic) population size for each country in a new plot.
Today, we'll discover how you can use the power of #rstats to create an interactive #shinyapp โจ
๐ก What is a ShinyApp?
Shiny is a framework that allows you to create web applications - ShinyApps โบ๏ธ You can use them for multiple purposes - to visualize data ๐จ (for instance the Scottish Household Survey by @ViktErik, bit.ly/3TqZevY, ...