Task 4: streamgraph. Use streamgraph to visualize a movie dataset, showing the number of…
- User
Task 4: streamgraph.
Use streamgraph to visualize a movie dataset, showing the number of movie genres over time.
first get the data from the package ggplot2movies
install.packages('ggplot2movies') library(ggplot2movies)
dat <- ggplot2movies::movies
The movies dataset is in the wide format for movie genres.
notice that streamgraph requires a long-format data.
Data shape can be wide or long.
In the wide format, each observation or case is represented by a single row, and each variable is represented by a separate column.
Wide data is often used when the variables are measured or recorded at a fixed set of time points or categories.
In the long format, the data is organized in a way that allows for multiple observations or measurements for each combination of variables.
Long data is often used when the variables are measured or recorded repeatedly over time or in different categories.
You will perform the following steps to generate the graph:
a) select columns of year and genre. notice that the data has a wide format
and you need to convert it into long format first.
hint: use the function "melt" from reshape2 library to convert the data frame
b) count the frequency of each genre per year
c) show the result with a streamgraph, and include a selection menu
- Assistant
To create a streamgraph in R, showcasing the frequency of each genre per year using the data from the package, follow these steps: