Get Certificate: Data Visualization with R Cognitive Class Exam Quiz Answers
Data Visualization with R Cognitive Class Certification Answers
Module 1 – Basic Visualization Tools
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
Module 2 – Basic Visualization Tools Continued
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
Module 3 – Specialized Visualization Tools
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
Module 4 – How to create Maps
Question 1: Which function gives an object that represents an empty world map
- addMarkers
- addTiles
- 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()
- addTiles()
- None of the above options are correct
Module 5 – How to build interactive web pages
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
Data Visualization with R Final Exam Answers – Cognitive Class
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”)
- download.file(“https://ibm.box.com/shared/static/cmid70rpa7xe4ocitcga1bve7r0kqnia.csv”, destfile = “/resources/data/my_data.csv”)
- download(“https://ibm.box.com/shared/static/cmid70rpa7xe4ocitcga1bve7r0kqnia.csv”, destfile = “/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
- addMarkers
- addTiles
- 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 specifically designed for statistical computing and graphics. It’s widely used by data analysts, statisticians, and researchers for data visualization due to its extensive collection of packages for statistical graphics and its flexibility in creating high-quality visualizations.
Here’s a basic overview to get you started:
Installing R and RStudio:
- Install R: Go to the R Project website and download the latest version of R for your operating system. Follow the installation instructions.
- Install RStudio (Optional but Recommended): RStudio is an integrated development environment (IDE) for R that provides a more user-friendly interface. You can download it from the RStudio website and install it on your computer.
Basics of Data Visualization in R:
- Loading Data: Before you can visualize data, you need to load it into R. You can do this using functions like
read.csv()
for CSV files,read.table()
for tabular data, orreadRDS()
for R Data Files. - Exploring Data: Once your data is loaded, it’s essential to explore it to understand its structure and contents. Functions like
head()
,summary()
, andstr()
are helpful for this purpose. - Choosing the Right Package: R offers several packages for data visualization. The most popular one is
ggplot2
, but there are others likeplotly
,lattice
, andggvis
. Each package has its strengths and weaknesses, so it’s essential to choose the one that best suits your needs. - Creating Basic Plots with ggplot2:
ggplot2
follows the grammar of graphics, which provides a structured way to create visualizations. - Customizing Plots:
ggplot2
allows for extensive customization of plots. You can modify the appearance of points, lines, axes, labels, and more using variousgeom_*
layers andtheme()
options. - Saving Plots: Once you’ve created a plot, you can save it as an image file using functions like
ggsave()
.
Further Learning:
- Online Resources: Websites like DataCamp, Coursera, and YouTube offer numerous tutorials and courses on data visualization with R.
- Books: Books like “ggplot2: Elegant Graphics for Data Analysis” by Hadley Wickham and “R for Data Science” by Garrett Grolemund and Hadley Wickham are excellent resources for learning data visualization in R.
- Practice: The best way to learn is by doing. Practice creating different types of plots with different datasets to gain proficiency.
Mastering data visualization takes time and practice, so don’t get discouraged if things seem challenging at first. Keep experimenting and learning, and you’ll soon become proficient in creating insightful visualizations with R!