Okay, so, I wanted to mess around with this thing called shiny and see what it’s all about. I heard it’s pretty cool for making interactive web apps with R, and since I’ve been dabbling in R lately, I figured, why not give it a shot?

First things first, I had to get shiny installed. That was easy enough. I just opened up RStudio and typed *("shiny")
into the console. Boom, done. Then, I loaded it up with library(shiny)
.
Next, I needed some data to play with. I found a simple dataset online about cars – you know, stuff like miles per gallon, horsepower, weight, that kind of thing. I saved it as a CSV file and loaded it into R using .
Now comes the fun part – building the app! With shiny, you basically create two main parts: a UI (user interface) part, which is what people will see and interact with, and a server part, which handles all the calculations and logic behind the scenes.
For the UI, I wanted to keep it simple. I decided to have a dropdown menu where users could select a variable from the car dataset, and then a plot would show up displaying that variable’s distribution. I used the selectInput()
function to create the dropdown and the plotOutput()
function to create a placeholder for the plot.
- Used
selectInput()
for the dropdown menu. - Used
plotOutput()
for the plot placeholder.
The server part was a bit trickier, but not too bad. I used the renderPlot()
function to tell shiny how to create the plot based on the user’s selection. Basically, I grabbed the selected variable from the input using input$variable_name
and then used R‘s plotting functions to create a histogram or a boxplot, depending on what made sense for that variable.

Once I had both the UI and server parts defined, I used the shinyApp()
function to combine them and launch the app. And there it was! My very own interactive web app, built with R and shiny. I could select different variables from the dropdown, and the plot would update automatically. Pretty neat, huh?
Making it fancier
I have to admit that the app is quite basic, there is not much content that can be displayed. I thought I could make it fancier. I want to show the data source code in my app, that would be cool!
I searched how to show the source code of my data and I found DT
package can do that. So, I installed it and added a new output using DT::dataTableOutput()
. Then, in the server part, I used DT::renderDataTable()
to handle the data table display.
Then I realize that the layout is terrible! I need something to make my app look better, I added a sidebar layout with sidebarLayout()
. The sidebarPanel()
is used to put the dropdown menu, and the mainPanel()
is used to contain the plot and the data table.
Finally, I got an interactive app that can show a plot and a data table in a well-organized layout. That was a fun little project! It showed me the power of shiny for creating interactive web apps without needing to know a lot of web development stuff. I’m definitely going to explore shiny more in the future. Maybe I’ll even build something more complex next time.
