BaşlayınÜcretsiz Başlayın

Converting a ggplot2 scatterplot

The ggplotly() command makes it easy to create interactive versions of most static plots created using the ggplot2 package. In this exercise, your task is to create an interactive version of the below scatterplot, exploring the relationship between video game sales in North America (NA_Sales) and aggregate critic score (Critic_Score) in 2016.

After creating the interactive graphic, be sure to explore what interactions are possible.

Note: loading plotly also loads ggplot2 and dplyr.

Bu egzersiz

Interactive Data Visualization with plotly in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Load plotly.
  • Create a scatterplot with NA_Sales on the x-axis and Critic_Score on the y-axis for video games found in the vgsales dataset from 2016. Store this plot in the scatter object.
  • Use the ggplotly() command to convert scatter to a plotly interactive graphic.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Load the plotly package
___

# Store the scatterplot of Critic_Score vs. NA_Sales sales in 2016
scatter <- ___ %>%
			filter(___ == ___) %>%
			ggplot(aes(x = ___, y = ___)) +
			geom_point(alpha = 0.3)

# Convert the scatterplot to a plotly graphic
___(___)
Kodu Düzenle ve Çalıştır