Tuesday , June 25 2024
Breaking News

# Data Visualization with R Cognitive Class Exam Quiz Answers

## Data Visualization with R Cognitive Class Certification Answers

Question 1: Choose the correct code from the following options to install the ggplot2 library in R.

• install.packages(ggplot2)
• install.package(“ggplot2”)
• install.packages(“ggplot2”)
• install.package(ggplot2)

Question 2: Select the correct code that provides numerical values to different segments of the pie chart?

• coord_polar(theta=’y’)
• coord_polar(‘y’)
• theta = coord_polar(‘y’)
• coord_polar()

Question 3: Select the correct code from the following options to remove the color of the bars in the histogram?

• xlab = 0
• alpha = I(0)
• binwidth = 0
• geom = 0

Question 1: Select the correct methods used to create a scatterplot in R?

• scatterplot3d()
• scatterplot()
• qplot()
• plot()
• All the above options are correct

Question 2: Select the correct parameter used to change the line width in a line graph using the geom_line() method?

• line_size
• size
• line_width
• width

Question 3: Which parameter out of the following represents the Confidence Interval in Regression?

• confidence_interval
• se
• ci
• lm

Question 1: Select the correct option for the values of Median, Lower whisker, Upper whisker, First quartile, Third quartile for the dataset: 3, 5, 7, 8, 12, 13, 14, 18, 21?

• 33, 2, 5, 12, 18
• 6, 2, 22, 7, 2
• 12, 4, 2, 3, 17
• 12, 3, 21, 6, 16

Question 2: >> True or False: To create waffle charts in R, we use ggplot library which is used for graphs and also waffle library.

• True
• False

Question 3: When working with Radar Charts in R, what is the correct code used to suppress the warnings generated?

• (warn = -1)
• (warn = 1)
• options(warn = -1)
• None of the options are correct

Question 1: Which function gives an object that represents an empty world map.

• leaflet
• None of the options are correct

Question 2: What is the use of the method addTiles() in R?

• To divide map in tiles.
• To zoom in the map to see different countries and streets in detail.
• To create tiles view of map.
• All the options above are correct

Question 3: ___________ method is used to publish a tile layer on the map.

• leaf()
• leaflet()
• None of the above options are correct

Question 1: Which function is used to create the display of shiny app?

• display()
• output functions
• fluidPage()
• input functions

Question 2: Which argument is used to position sliderbar on the right hand side in shiny app?

• align=”right”
• position=”right”
• position = “rightalign”
• sliderLayout(position=”right”)

Question 3: >>What does the ui.R file in R contain?

• inputs for server.R
• layout and appearance of app.
• instructions to build output object.
• All the above options are correct

Question 1: Which of the following options indicate the features that make R suitable for Data Visualizations

• R is a free and open source tool
• Built for statistical computing
• Visualization Tools
• All the options above are correct

Question 2: if(“ggplot2” %in% rownames(installed.packages()) == FALSE) {install.packages(“ggplot2”)}library(ggplot2) Please select the correct explanation for the code from the following options

• Check if “ggplot2” library is already installed into R, if not then install it and load it into R environment
• Load the “ggplot2”library into R environment
• Install and load the “ggplot2” library into R environment
• Install the “ggplot2” library into R

Question 3: We want to create a Bar Graph with black filled bars, x and y axis labels as Cylinders and Number of cars respectively and outline color of bars as Red. Choose the correct code block from below which will create the desired graph.

• qplot(mtcars\$cyl, geom = “bar”, fill = I(“black”), xlab = “Cylinders”, ylab = “Number of Cars”, colour = I(“red”))
• qplot(mtcars\$cyl, geom = “histogram”, fill = I(“black”), xlab = “Cylinders”, ylab = “Number of Cars”, colour=I(“red”))
• qplot(mtcars\$cyl, fill = I(“black”), xlab = “Cylinders”, ylab=”Number of Cars”, outline=I(“red”)
• None of the options are correct

Question 4: Choose the correct parameter which will define the width of the bars in a Histogram.

• binwidth
• barWidth
• bar_width(value)
• width
• None of the options are correct

Question 5: A pie chart in ggplot2 is a transformed stacked bar plot. Select the correct function from the following options to convert a stacked bar plot into a pie chart?

• pieChart (theta=’y’)
• coord_polar(theta=’y’)
• transform(theta=’y’)
• None of the above options are correct

Question 6: Let’s assume we have the mtcars dataset and we want to create a Scatter Plot by using mpg and wt columns of this dataset. Select the correctcode from the options below which can create the plot for us with red colored points.

• ggplot(mtcars,aes(x=mpg,y=wt)) + geom_point()
• ggplot(mtcars,aes(x=mpg,y=wt)) + geom_point(shape=19, colour=”red”)
• ggplot(mtcars,aes(x=mpg,y=wt)) + geom_point(shape=19, “blue”)
• None of the options above are correct

Question 7: True or False: It is possible plot more than one line at a time in the same graph using the ggplot() method

• False
• True

Question 8: Choose the correct statement from the following options

• se parameter is used to display confidence interval
• There is no term Confidence Interval in Regression
• If you want to display confidence interval then either just ignore the se attribute, or set it to TRUE
• None of above options are correct

Question 9: Suppose we want to download a .csv file from the link below, https://ibm.box.com/shared/static/cmid70rpa7xe4ocitcga1bve7r0kqnia.csv and store it with name my_data.csv in “/resources/data/” folder. Select the correct code from the options below

• file(“https://ibm.box.com/shared/static/cmid70rpa7xe4ocitcga1bve7r0kqnia.csv”, “/resources/data/my_data.csv”)
• None of the options are correct

Question 10: Select the correct format from the following options to create a word cloud with a minimum frequency value 1 and maximum words 200?

• wordcloud(words = data, freq = frequency, min.freq = 1, max.words=200)
• wordcloud(data, frequency, minimun= 1, max.words=200)
• wordcloud(freq = frequency, min.freq = 1, maxWords=200)
• wordcloud(words = data, freq = frequency, min.freq = 1)

Question 11: Select the correct option to create a WordCloud that is centered?

• order = FALSE
• random.order = TRUE
• random.order = FALSE
• random = TRUE

Question 12: dplyr and Scales libraries in a Radar Chart are used for?

• filtering the dataset
• provides convenient viewing and utility functions
• pipe operations and to determine labels respectively
• None of the options are correct

Question 13: Which method is used to avoid displaying warnings, generated while Creating a Radar Chart?

• options(warns=-1)
• warns(-1)
• options(warn=-1)
• warnings(-1)

Question 14: ___________ can be used to adjust the size of Waffle Charts

• kernel
• IRkernel
• Ikernel
• None of the options are correct

Question 15: >> Which of the following parameters are used to create waffle charts in R?

• colors
• rows
• title
• xlab
• All the options above are correct

Question 16: Choose the correct method to create a Box Plot in R

• ggplot(df) + geom_boxplot()
• ggplot(df, aes(x=label, y=value))
• ggplot(df, aes(x=label, y=value)) + geom_boxplot()
• None of the options are correct

Question 17: What is the term used to indicate the difference between the first and third quartiles?

• lower whisker and upper whisker.
• first quartile
• third quartile
• Interquartile Range

Question 18: Which function gives an object that represents an empty world map

• leaflet
• All the options above are correct

Question 19: What is the use of the method addTiles() in R?

• To divide map in tiles.
• To zoom in the map to see different countries and streets in detail.
• To create tiles view of map.
• All the options above are correct

Question 20: Which function is used to create display of shiny app?

• display()
• output functions
• fluidPage()
• input functions

## Introduction to Data Visualization with R

R is a powerful programming language and environment for statistical computing and graphics. It’s widely used in academia, research, and industry for data analysis, visualization, and statistical modeling.

Here’s a brief overview of how you can get started with data visualization in R:

1. Install R and RStudio: Before you can start visualizing data, you need to install R and RStudio. R is the programming language itself, while RStudio is an integrated development environment (IDE) that provides a more user-friendly interface for working with R. Both are free and can be downloaded from their respective websites.
2. Load Data: Once you have R and RStudio installed, you can begin by loading your data into R. R can handle various types of data formats, such as CSV, Excel, or databases. You can use functions like read.csv() or read_excel() from the readr or readxl packages to import your data into R.
3. Explore Your Data: Before creating visualizations, it’s essential to explore your data to understand its structure, summary statistics, and relationships between variables. R provides various functions for data manipulation and exploration, such as summary(), str(), head(), tail(), and many more.
4. Choose the Right Visualization: Selecting the appropriate type of visualization depends on the nature of your data and the insights you want to convey. R offers a wide range of packages for creating different types of plots, including scatter plots, bar plots, histograms, boxplots, line graphs, heatmaps, and more. Some popular visualization packages in R include ggplot2, plotly, ggvis, lattice, and ggplotly.
5. Create Visualizations: Once you’ve decided on the type of visualization you want to create, you can use R to generate it. For example, if you’re using ggplot2, you can start by creating a plot object using the ggplot() function and then adding layers to customize the plot using various geoms (geometric objects) and aesthetics.
6. Customize Your Visualizations: R provides extensive options for customizing your visualizations, including changing colors, labels, titles, axes, legends, and more. You can use additional functions and arguments to modify the appearance and layout of your plots to make them more informative and visually appealing.
7. Save and Share Your Visualizations: Once you’ve created your visualizations, you can save them as image files (e.g., PNG, JPEG, PDF) or interactive web graphics (e.g., HTML, JavaScript) using R. You can also embed your visualizations in reports, presentations, or web applications to share your insights with others.

Overall, R is a versatile tool for data visualization, offering a wide range of capabilities for exploring, analyzing, and communicating insights from your data. With practice and experimentation, you can create informative and compelling visualizations to help tell stories and make data-driven decisions.