Skip to content
R for the Rest of Us: A Statistics-Free Introduction is out now! Check it out →
R for the Rest of Us Logo

Integrating Plotly with Shiny

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

In the plotly/assignment_02/app.R file, change the renderPlot to renderPlotly and plotOutput to plotlyOutput.

Fix the ggplotly() statement. What goes in this statement?

Learn More

library(shiny)
library(dplyr)
library(fivethirtyeight)
library(ggplot2)
library(plotly)
data(biopics)
biopics <- biopics |> filter(!is.na(box_office))

ui <- fluidPage(
  plotlyOutput("paired_plot")
)

server <- function(input, output) {
  
  output$paired_plot <- renderPlotly({
    
    out_plot <- ggplot(biopics) + 
      aes(x=year_release, 
          y=box_office, 
          color= type_of_subject,
          title=title) +
      geom_point()
    
    ggplotly(out_plot)
  })
  
}

shinyApp(ui = ui, server = server)

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.