QuiztudyPREMIUM
Google Data Analytics Professional Certificate • STUDY MODE
PRACTICE QUIZ
QUESTION 1 OF 41
Which of the following are operations you can perform in ggplot2? Select all that apply.
A
Add a title and subtitle to your plotCorrect AnswerB
Create scatterplots and bar chartsCorrect AnswerC
Automatically clean data before creating a plotD
Change the colors and dimensions of your plotCorrect AnswerQUESTION 2 OF 41
Which ggplot function is used to define the mappings of variables to visual representations of data?
A
ggplot()B
aes()Correct AnswerC
annotate()D
mapping()QUESTION 3 OF 41
A data analyst creates a plot using the following code chunk: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) Which of the following represents a function in the code chunk? Select all that apply.
A
The geom_point functionCorrect AnswerB
The aes functionCorrect AnswerC
The ggplot functionCorrect AnswerD
The data functionQUESTION 4 OF 41
A data analyst is working with the following plot and gets an error caused by a bug. What is the cause of the bug? ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)
A
The plus sign should be at the beginning of the second line.B
A missing closing parenthesis needs to be added.Correct AnswerC
The code uses a plus sign instead of a pipe.D
A function name needs to be capitalized.QUESTION 5 OF 41
You are working with the penguins dataset. You create a scatterplot with the following lines of code: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) + What code chunk do you add to the third line to save your plot as a pdf file with “penguins” as the file name?
A
ggsave(penguins.pdf)B
ggsave(=penguins)C
ggsave(“penguins.pdf”)Correct AnswerD
ggsave(“pdf.penguins”)QUESTION 6 OF 41
Which of the following are benefits of using ggplot2? Select all that apply.
A
Customize the look and feel of visualsCorrect AnswerB
Make complex data easier to understandCorrect AnswerC
Create plots using a single functionD
Automatically version control plotsQUESTION 7 OF 41
In ggplot2, what symbol do you use to add layers to your plot?
A
The pipe operator (%>%)B
The ampersand symbol (&)C
The plus sign (+)Correct AnswerD
The equals sign (=)QUESTION 8 OF 41
A data analyst creates a plot using the following code chunk: ggplot(data = buildings) + geom_bar(mapping = aes(x = construction_year, color = height)) Which of the following represents a variable in the code chunk?
A
construction_yearCorrect AnswerB
dataC
ggplotD
mappingQUESTION 9 OF 41
Which code snippet will make all of the bars in the plot have different colors based on their heights? geom_bar(mapping = aes(x = construction_year)) + color(“height”) geom_bar(mapping = aes(x = construction_year), color=height) geom_bar(mapping = aes(x = construction_year, color=height)) (CORRECT) geom_bar(mapping = aes(x = construction_year)) + color(height)
A
ggplot(data = buildings) +B
ggplot(data = buildings) +C
ggplot(data = buildings) +D
ggplot(data = buildings) +QUESTION 10 OF 41
A data analyst is working with the penguins data. The analyst creates a scatterplot with the following code: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g, alpha = species)) What does the alpha aesthetic do to the appearance of the points on the plot?
A
Makes the points on the plot largerB
Makes the points on the plot more colorfulC
Makes some points on the plot more transparentCorrect AnswerD
Makes the points on the plot smallerQUESTION 11 OF 41
What function creates a scatterplot and then adds a small amount of random noise to each point in the plot to make the points easier to find?
A
The geom_jitter() functionCorrect AnswerB
The geom_smooth() functionC
The geom_point() functionD
The geom_bar() functionQUESTION 12 OF 41
A data analyst uses the annotate() function to create a text label for a plot. Which attributes of the text can the analyst change by adding code to the argument of the annotate() function? Select all that apply.
A
Change the text into a title for the plot.B
Change the size of the text.Correct AnswerC
Change the font style of the text.Correct AnswerD
Change the color of the text.Correct AnswerQUESTION 13 OF 41
You are working with the penguins dataset. You create a scatterplot with the following lines of code: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) + What code chunk do you add to the third line to save your plot as a png file with “penguins” as the file name?
A
ggsave(“png.penguins”)B
ggsave(penguins.png)C
ggsave(“penguins.png”)Correct AnswerD
ggsave(“penguins”)QUESTION 14 OF 41
Which of the following tasks can you complete with ggplot2 features? Select all that apply.
A
Add labels and annotations to a plotCorrect AnswerB
Automatically clean data before creating a plotC
Create many different types of plotsCorrect AnswerD
Customize the visual features of a plotCorrect AnswerQUESTION 15 OF 41
Which code snippet will make all of the bars in the plot have different colors and shapes based on their heights? geom_bar(mapping = aes(x = construction_year)) + color(height) + shape(height) geom_bar(mapping = aes(x = construction_year, color=height, shape=height)) (CORRECT) geom_bar(mapping = aes(x = construction_year, color=[height, height])) geom_bar(mapping = aes(x = construction_year, color=height), aes(shape=height))
A
ggplot(data = buildings) +B
ggplot(data = buildings) +C
ggplot(data = buildings) +D
ggplot(data = buildings) +QUESTION 16 OF 41
A data analyst is working with the following plot and gets an error caused by a bug. What is the cause of the bug? ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g))
A
A missing closing parenthesis needs to be added.B
A function name needs to be capitalized.C
The plus should be at the end of the fist line.Correct AnswerD
The code uses a plus sign instead of a pipe.QUESTION 17 OF 41
A data analyst creates a plot with the following code chunk: ggplot(data = penguins) + geom_jitter(mapping = aes(x = flipper_length_mm, y = body_mass_g)) What does the geom_jitter() function do to the points in the plot?
A
Adds a small amount of random shapes at each point in the plotB
Adds random colors to each point in the plotC
Adds a small amount of random noise to each point in the plotCorrect AnswerD
Decrease the size of each point in the plotQUESTION 18 OF 41
Which aesthetic of the geom_smooth function can be used to change the style of the line?
A
lineB
linetypeCorrect AnswerC
linestyleD
linelookQUESTION 19 OF 41
Which of the following statements best describes a facet in ggplot?
A
Facets are subplots that display data for each value of a variable.Correct AnswerB
Facets are the text used in and around plots.C
Facets are the ggplot terminology for a chart axis.D
Facets are the visual characteristics of geometry objects.QUESTION 20 OF 41
When creating a plot in ggplot you must set the mapping argument of a function. Which function has the mapping argument?
A
The annotate functionB
The geometric functionCorrect AnswerC
The ggplot functionD
The aesthetic functionQUESTION 21 OF 41
A data analyst creates a plot using the following code chunk: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) Which of the following represents an aesthetic attribute in the code chunk? Select all that apply.
A
body_mass_gB
flipper_length_mmC
xCorrect AnswerD
yCorrect AnswerQUESTION 22 OF 41
A data analyst creates a scatterplot with many data points. The analyst wants to make some points on the plot more transparent than others. What aesthetic should the analyst use?
A
AlphaCorrect AnswerB
FillC
ShapeD
ColorQUESTION 23 OF 41
Fill in the blank: You can use the _____ function to put a text label on your plot to call out specific data points.
A
annotate()Correct AnswerB
geom_smooth()C
facet_grid()D
ggplot()QUESTION 24 OF 41
A data analyst has a scatter plot with crowded points that make it hard to identify a trend. What geometry function can they add to their plot to clearly indicate the trend of the data?
A
geom_bar()B
geom_smooth()Correct AnswerC
geom_jitter()D
geom_alpha()QUESTION 25 OF 41
A data analyst is working with the following plot and gets an error caused by a bug. What is the cause of the bug? ggplot(data = penguins) %>% geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g))
A
A missing closing parenthesis needs to be added.B
A function name needs to be capitalized.C
The pipe should be at the beginning of the second line.D
The code uses a pipe instead of a plus sign.Correct AnswerQUESTION 26 OF 41
Fill in the blank: In ggplot2, the term mapping refers to the connection between variables and _____ .
A
aestheticsCorrect AnswerB
facetsC
geomsD
data framesQUESTION 27 OF 41
A data analyst creates a bar chart with the diamonds dataset. They begin with the following line of code: ggplot(data = diamonds) What symbol should the analyst put at the end of the line of code to add a layer to the plot?
A
The plus sign (+)Correct AnswerB
The ampersand symbol (&)C
The equals sign (=)D
The pipe operator (%>%)QUESTION 28 OF 41
You are working with the penguins dataset. You create a scatterplot with the following code: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) You want to highlight the different years of data collection on your plot. Add a code chunk to the second line of code to map the aesthetic size to the variable year. NOTE: the three dots (...) indicate where to add the code chunk. You may need to scroll in order to find the dots. geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g, ...)) What years does your visualization display?
A
2005-2009B
2007-2009Correct AnswerC
2007-2011D
2006-2010Explanation:
You add the code chunk size = year to map the aesthetic size to the variable year. The correct code is ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g, size = year)). Inside the parentheses of the aes() function, after the comma that follows y = body_mass_g, write the aesthetic (size), then an equals sign, then the variable (year). The data points for the different years now appear in different sizes. Your visualization displays the years 2007-2009.
QUESTION 29 OF 41
Fill in the blank: The _____ creates a scatterplot and then adds a small amount of random noise to each point in the plot to make the points easier to find.
A
geom_jitter() functionCorrect AnswerB
geom_smooth() functionC
geom_point() functionD
geom_bar() functionQUESTION 30 OF 41
What function can be used to facet a plot on two variables?
A
geom_wrap()B
facet_grid()Correct AnswerC
facet_layout()D
facet_wrap()QUESTION 31 OF 41
What argument of the labs() function can a data analyst use to add text outside of the grid area of a plot?
A
textB
annotateC
titleCorrect AnswerD
noteQUESTION 32 OF 41
In R studio, what default options does the Export functionality of the Plots tab give for exporting plots?
A
HTMLB
SlideshowC
ImageCorrect AnswerD
PDFCorrect AnswerQUESTION 33 OF 41
You are working with the penguins dataset. You create a scatterplot with the following code chunk: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) You want to highlight the different penguin species in your plot. Add a code chunk to the second line of code to map the aesthetic size to the variable bill_depth_mm. NOTE: the three dots (...) indicate where to add the code chunk. You may need to scroll in order to find the dots. geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g, ...)) Which approximate range of bill depths does your visualization display?
A
20 - 31B
14 - 20Correct AnswerC
31 - 40D
2 - 9QUESTION 34 OF 41
Which of the following is a functionality of ggplot2?
A
Combine data manipulation and visualizations using pipes.Correct AnswerB
Filter and sort data in complex ways.C
Define complex visualization using a single function.D
Create plots using artificial intelligence.QUESTION 35 OF 41
A data analyst creates a scatterplot. The analyst wants to put a text label on the plot to call out specific data points. What function does the analyst use?
A
The annotate() functionCorrect AnswerB
The geom_smooth() functionC
The facet_grid() functionD
The ggplot() functionQUESTION 36 OF 41
You are working with the penguins dataset. You create a scatterplot with the following code chunk: ggplot(data = penguins) + geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g)) You want to highlight the different penguin species in your plot. Add a code chunk to the second line of code to map the aesthetic shape to the variable species. NOTE: the three dots (...) indicate where to add the code chunk. You may need to scroll in order to find the dots. geom_point(mapping = aes(x = flipper_length_mm, y = body_mass_g, ...)) Which species tends to have the longest flipper length and highest body mass?
A
ChinstrapB
AdelieC
GentooCorrect AnswerD
MacaroniQUESTION 37 OF 41
What is the purpose of the facet_wrap() function?
A
Create text inside a plot areaB
Create subplots of a single variable into separate categoriesCorrect AnswerC
Modify the visual characteristic of a data pointD
Modify ggplot visuals to be three-dimensionalQUESTION 38 OF 41
Which statement about the ggsave() function is correct?
A
ggsave() is the only way to export a plot.B
ggsave() exports the last plot displayed by default.Correct AnswerC
ggsave() is run from the Plots Tab in RStudio.D
ggsave() is unable to save .png files.QUESTION 39 OF 41
A data analyst creates a scatterplot where the points are very crowded, which makes it hard to notice when points are stacked. What change can they make to their scatter plot to make it easier to notice the stacked data points?
A
Change geom_point() to geom_jitter()Correct AnswerB
Change the shape of the pointsC
Change ggplot() to ggplot2()D
Change the color of the pointsQUESTION 40 OF 41
A data analyst wants to add a large piece of text above the grid area that clearly defines the purpose of a plot. Which ggplot function can they use to achieve this?
A
annotate()B
labs()Correct AnswerC
subtitle()D
title()QUESTION 41 OF 41
You are working with the diamonds dataset. You create a bar chart with the following code: ggplot(data = diamonds) + geom_bar(mapping = aes(x = color, fill = cut)) + You want to use the facet_wrap() function to display subsets of your data. Add the code chunk that lets you facet your plot based on the variable clarity. ggplot(data = diamonds) + geom_bar(mapping = aes(x = color, fill = cut)) + facet_wrap(~clarity) how many subplots does your visualization show?
A
8B
9C
6D
7Correct AnswerReady to test your recall?
Which of the following are operations you can perform in ggplot2? Select all that apply.
💡Select all 3 correct answers before submitting (0 of 3 selected).
A
Add a title and subtitle to your plot
B
Create scatterplots and bar charts
C
Automatically clean data before creating a plot
D
Change the colors and dimensions of your plot
How confident are you in this answer?