Skip to content

Quiz 2 :Developing Data Products (Data Science Specialization) Answers 2025

Question 1 – What is rmarkdown? (Check all that apply)

✅ A format that can be interpreted into markdown (which is a simplified markup language).
✅ A simplified format that, when interpreted, incorporates your R analysis into your document.
❌ A form of LaTeX typesetting.
❌ A simplified XML format that can be interpreted into R.

Explanation:
R Markdown combines plain text (Markdown syntax) with embedded R code chunks, allowing automatic integration of code results (figures, tables, etc.) into reports. It’s not XML or LaTeX itself (though it can render to LaTeX via pandoc).


Question 2 – Which chunk option prevents R code from being shown in the output?

echo = FALSE
cache = FALSE
comment = FALSE
eval = FALSE

Explanation:
echo = FALSE hides the code, but still shows results/plots.

  • eval = FALSE prevents running code.

  • cache affects speed (stores results).

  • comment controls how output is prefixed.


Question 3 – Which chunk option prevents code from being run/interpreted?

eval = FALSE
run = FALSE
cache = FALSE
eval = NULL

Explanation:
Setting eval = FALSE means R will not execute the code in that chunk—it just displays the code (if echo=TRUE).


Question 4 – What is leaflet? (Check all that apply)

✅ An R package interface to the JavaScript library of the same name.
✅ A JavaScript library for creating interactive maps.
❌ A tool for reproducible documents.
❌ An R package for creating 3D rendered isomaps.

Explanation:
Leaflet is a popular JavaScript library for interactive web maps, and the R leaflet package exposes this functionality inside R. It’s not for 3D rendering or reproducible reports.


Question 5 – The R command

df %>% leaflet() %>% addTiles()

is equivalent to what? (Check all that apply)

leaflet(df) %>% addTiles()
addTiles(leaflet(df))
leaflet(addTiles(df))
df(leaflet(addTiles()))
addTiles(leaflet(df()))

Explanation:
The pipe operator %>% forwards the left-hand object (df) into the first argument of the next function, so both these forms are equivalent:

leaflet(df) %>% addTiles()
addTiles(leaflet(df))

Question 6 – If I want to add popup icons to my leaflet map in R, I should use:

addMarkers
dplyr
leaflet
addTiles

Explanation:
addMarkers() is the Leaflet function used to add pins/markers (which can include popups or icons) to maps.


🧾 Summary Table

Q# ✅ Correct Answer(s) Key Concept
1 rmarkdown combines text & R code ✅✅ Dynamic reproducible documents
2 echo = FALSE Hides code in output
3 eval = FALSE Prevents code execution
4 R + JS library for interactive maps ✅✅ leaflet = mapping interface
5 leaflet(df) %>% addTiles() ✅, addTiles(leaflet(df)) %>% pipes input correctly
6 addMarkers Add popups/icons to Leaflet maps