7.4.4.Weekly challenge 4 - quanganh2001/Google-Data-Analytics-Professional-Certificate-Coursera GitHub Wiki

Glossary: Terms and definitions

We’ve covered a lot of terms—some of which you may have already known, and some of which are new. To make it easy to remember what a word means, we created this glossary of terms and definitions.

To use the glossary for this course item, click the link below and select “Use Template.”

Link to glossary: Week 4 Glossary

OR

If you don’t have a Google account, you can download the glossary directly from the attachment below.

Course 7 Week 4 Glossary _ DA terms and definitions

Weekly challenge 4

1st

Question 1

Which of the following statements about ggplot is true?

A. ggplot is designed to make cleaning data easy.

B. ggplot allows analysts to create different types of plots.

C. ggplot allows analysts to create plots using a single function.

D. ggplot is the default plotting package in base R.

The correct answer is B. ggplot allows analysts to create different types of plots.

Question 2

In ggplot2, what symbol do you use to add layers to your plot?

A. The ampersand symbol (&)

B. The plus sign (+)

C. The pipe operator (%>%)

D. The equals sign (=)

The correct answer is B. The plus sign (+)

Question 3

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 function in the code chunk?

A. The mapping function

B. The height function

C. The x function

D. The ggplot function

The correct answer is D. The ggplot function

Question 4

Which code snippet will make all of the bars in the plot have different colors and shapes based on their heights?

A. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=[height, height]))

B. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year)) +

color(height) +

shape(height)

C. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=height, shape=height))

D. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=height), aes(shape=height))

The correct answer is C.

Question 5

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 function name needs to be capitalized.

B. The pipe should be at the beginning of the second line.

C. A missing closing parenthesis needs to be added.

D. The code uses a pipe instead of a plus sign.

The correct answer is D. The code uses a pipe instead of a plus sign.

Question 6

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, shape = species))

Output:

image

Which species tends to have the longest flipper length and highest body mass?

A. Gentoo

B. Adelie

C. Macaroni

D. Chinstrap

The correct answer is A. Gentoo

Question 7

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 noise to each point in the plot

B. Adds random colors to each point in the plot

C. Adds a small amount of random shapes at each point in the plot

D. Decrease the size of each point in the plot

Question 8

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 color.

facet_wrap(~color)

Output:

image

How many subplots does your visualization show?

A. 7

B. 6

C. 9

D. 8

The correct answer is A. 7. Explain: You add the code chunk facet_wrap(~color) to facet your plot based on the variable color. The correct code is ggplot(data = diamonds) + geom_bar(mapping = aes(x = color, fill = cut)) + facet_wrap(~color). Inside the parentheses of the facet_wrap() function, write a tilde symbol (~) followed by the name of the variable you want to facet. The facet_wrap() function lets you display subsets of your data.

Your visualization shows 7 subplots.

Question 9

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. labs()

B. title()

C. annotate()

D. subtitle()

The correct answer is A. labs().

Question 10

By default, what plot does the ggsave() function export?

A. The plot define the plots.config file

B. The first plot displayed

C. The plot defined in the Plots Tab of R Studio

D. The last displayed plot

The correct answer is D. The last displayed plot

2nd

Question 1

Which of the following are benefits of using ggplot2? Select all that apply.

  • Customize the look and feel of visuals
  • Automatically version control plots
  • Create plots using a single function
  • Make complex data easier to understand

Question 2

In ggplot2, what symbol do you use to add layers to your plot?

A. The ampersand symbol (&)

B. The pipe operator (%>%)

C. The plus sign (+)

D. The equals sign (=)

The correct answer is C. The plus sign (+)

Question 3

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. mapping

B. construction_year

C. ggplot

D. data

The correct answer is B. construction_year

Question 4

Which code snippet will make all of the bars in the plot purple?

A. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=height))

B. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year)) +

color(“purple”)

C. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=”purple”))

D. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year), color=”purple”)

The correct answer is D.

Question 5

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. The pipe should be at the beginning of the second line.

C. A function name needs to be capitalized.

D. The code uses a pipe instead of a plus sign.

The correct answer is D. The code uses a pipe instead of a plus sign.

Question 6

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, shape = species))

Output:

download

Which species tends to have the longest flipper length and highest body mass?

A. Chinstrap

B. Macaroni

C. Gentoo

D. Adelie

The correct answer is C. Gentoo

Question 7

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_alpha()

B. geom_bar()

C. geom_jitter()

D. geom_smooth()

The correct answer is D. geom_smooth()

Question 8

What function can be used to facet a plot on two variables?

A. facet_wrap()

B. geom_wrap()

C. facet_layout()

D. facet_grid()

The correct answer is D. facet_grid()

Question 9

A data analyst wants to add text elements inside the grid area of their plot. Which ggplot function allows them to do this?

A. text()

B. labs()

C. annotate()

D. facet()

The correct answer is C. annotate()

Question 10

Which statement about the ggsave() function is correct?

A. ggsave() is the only way to export a plot.

B. ggsave() is run from the Plots Tab in RStudio.

C. ggsave() is unable to save .png files.

D. ggsave() exports the last plot displayed by default.

The correct answer is D. ggsave() exports the last plot displayed by default.

3rd

Passed 100%

Question 1

Which of the following are operations you can perform in ggplot2? Select all that apply.

  • Change the colors and dimensions of your plot
  • Automatically clean data before creating a plot
  • Create scatterplots and bar charts
  • Add a title and subtitle to your plot

Question 2

A data scientist wants to change the initial dataset they are using for a scatter plot. What function’s argument should they change to specify the new data?

A. aes()

B. geom_point()

C. mapping()

D. ggplot()

The correct answer is D. ggplot()

Question 3

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. ggplot

B. data

C. mapping

D. construction_year

The correct answer is D. construction_year

Question 4

Which code snippet will make all of the bars in the plot have different colors and shapes based on their heights?

A. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=height, shape=height))

B. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year)) +

color(height) +

shape(height)

C. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=[height, height]))

D. ggplot(data = buildings) +

geom_bar(mapping = aes(x = construction_year, color=height), aes(shape=height))

The correct answer is A.

Question 5

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 some points on the plot more transparent

B. Makes the points on the plot larger

C. Makes the points on the plot smaller

D. Makes the points on the plot more colorful

The correct answer is A. Makes some points on the plot more transparent

Question 6

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 years of data collection on your plot. Add a code chunk to the second line of code to map the aesthetic alpha to the variable island.

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, shape=island))

Output:

image

What islands does your visualization display?

A. Cebu, Java, Hispaniola

B. Biscoe, Dream, Torgersen

C. Biscoe, Java, Buton

D. Cebu, Borneo, Torgersen

The correct answer is B. Biscoe, Dream, Torgersen

Question 7

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_alpha()

B. geom_jitter()

C. geom_bar()

D. geom_smooth()

The correct answer is D. geom_smooth()

Question 8

Which of the following statements best describes a facet in ggplot?

A. Facets are the text used in and around plots.

B. Facets are the ggplot terminology for a chart axis.

C. Facets are the visual characteristics of geometry objects.

D. Facets are subplots that display data for each value of a variable.

The correct answer is D. Facets are subplots that display data for each value of a variable.

Question 9

What argument of the labs() function can a data analyst use to add text outside of the grid area of a plot?

A. title

B. annotate

C. text

D. note

The correct answer is A. title

Question 10

By default, what plot does the ggsave() function export?

A. The last displayed plot

B. The plot defined in the Plots Tab of R Studio

C. The plot define the plots.config file

D. The first plot displayed

The correct answer is A. The last displayed plot