Enhance your R skills with these 30 multiple-choice questions on advanced data visualization techniques, including interactive plots with Plotly and Shiny, animated visualizations with gganimate, and dashboard creation.
Chapter: Advanced Data Visualization in R – MCQs
1. Interactive Plots with Plotly and Shiny (10 Questions)
Which R package is used to create interactive plots? a) ggplot2 b) plotly c) lattice d) base
How do you create an interactive plot using the plotly package in R? a) plot() b) plot_ly() c) ggplot() d) interactive_plot()
In which of the following contexts is the Shiny package used in R? a) Creating interactive visualizations b) Building web applications c) Implementing machine learning models d) Generating static plots
Which function in Shiny is used to create a UI (user interface)? a) uiOutput() b) fluidPage() c) renderUI() d) server()
How do you add interactivity to a Plotly graph in R? a) Using plot() b) By adding a renderPlot() function c) Using plot_ly() and setting attributes d) Using ggplot() with interactive options
What is the primary purpose of the renderPlotly() function in Shiny? a) Display the plot as a static image b) Render the plot interactively in the UI c) Save the plot as a file d) Export the plot to a PDF
Which Shiny function is used to create a reactive output in the server function? a) reactive() b) renderText() c) output$variable d) renderPlot()
Which of the following is a feature of interactive plots created with Plotly in R? a) Zoom and pan b) Color change based on data c) Hover information d) All of the above
Which of the following is necessary to run a Shiny app? a) runApp() b) shinyApp() c) runServer() d) startShinyApp()
What is the primary use case of the shiny::fluidPage() function in R? a) To define the layout of the UI b) To create an interactive plot c) To generate static graphs d) To store server-side logic
Which package in R is used for creating animated visualizations? a) ggplot2 b) plotly c) gganimate d) animation
How do you create an animated plot in R using gganimate? a) gganimate() b) animate() c) plot_ly() d) gif_plot()
In gganimate, which function is used to specify the variable that changes over time? a) transition_time() b) transition_states() c) transition_manual() d) transition_plot()
Which of the following formats can you use to save animated plots in R with gganimate? a) MP4 b) GIF c) PNG d) Both a and b
What is the purpose of the enter_fade() function in gganimate? a) To specify how the plot enters b) To specify the colors of the plot c) To specify how the plot fades out d) To animate the background
Which function in gganimate helps to transition between states in an animation? a) transition_states() b) transition_time() c) transition_layers() d) transition_path()
In gganimate, which aesthetic element is typically animated over time? a) color b) size c) position d) All of the above
Which of the following would you use in gganimate to make a plot dynamic over multiple time points? a) transition_states() b) transition_time() c) transition() d) transition_interactive()
How do you change the speed of the animation in gganimate? a) Adjust the duration parameter b) Set the fps (frames per second) parameter c) Use frame_speed() d) Both a and b
What does the animate() function in gganimate return? a) A plotly object b) An animated ggplot object c) A static plot d) A reactive plot
3. Creating Dashboards (10 Questions)
Which R package is commonly used for creating dashboards? a) ggplot2 b) shiny c) plotly d) d3.js
In a Shiny dashboard, which component defines the header of the dashboard? a) dashboardBody() b) dashboardHeader() c) dashboardSidebar() d) dashboardFooter()
How do you organize the content of a Shiny dashboard in R? a) Using fluidPage() b) Using dashboardPage() c) Using server() d) Using renderUI()
What is the purpose of the box() function in a Shiny dashboard? a) To create a data input field b) To define a layout for visual components c) To create a plot d) To define server logic
In a Shiny dashboard, which function is used to display the main body content? a) bodyContent() b) renderBody() c) dashboardBody() d) bodyLayout()
Which function in Shiny is used to generate a sidebar for the dashboard? a) dashboardSidebar() b) sidebarPanel() c) sidebarLayout() d) sidebarMenu()
In Shiny, which function is used to dynamically render a plot? a) renderPlot() b) plotOutput() c) renderChart() d) plotDisplay()
Which of the following is used to create a dropdown menu in a Shiny dashboard? a) selectInput() b) dropdownMenu() c) radioButtons() d) actionButton()
How can you add a title to a Shiny dashboard? a) titlePanel() b) dashboardTitle() c) dashboardHeader() d) headerPanel()
Which layout function in Shiny is used to define the overall layout structure of the dashboard? a) fluidPage() b) dashboardPage() c) layoutPage() d) shinyLayout()