What does wrapping a data frame in knitr::kable() accomplish, compared to letting R print the data frame directly?
- Wrong:
kable()produces a table, not a figure. - Correct:
kable()produces a clean, document-formatted table instead of R’s raw console output. - Wrong:
kable()only changes how the data is displayed, not the underlying values. - Wrong:
kable()does not automatically round values; rounding must be done separately if desired.
What do the fig-width and fig-height chunk options control?
- Wrong: showing or hiding code is controlled by
echo, not the figure sizing options. - Wrong: the color palette is determined by the plotting code itself, not by these chunk options.
- Correct:
fig-widthandfig-heightset the rendered figure’s dimensions, in inches. - Wrong: the caption is set with
fig-cap, notfig-width/fig-height.
You include a local image in a page using a plain relative path, images/photo.jpg. The image displays correctly on that page, but breaks when the same image is included from a page in a different folder. What is the most reliable fix?
- Wrong: renaming the file doesn’t address how the path is resolved.
- Wrong: duplicating the image across folders works but isn’t a reliable or maintainable fix.
- Correct: a leading
/makes the path resolve from the project root regardless of which page includes it. - Wrong: the file format has no bearing on how the path is resolved.
Why is it generally recommended to export figures as vector graphics (e.g., PDF or SVG) rather than a raster format (e.g., PNG or JPEG) for a report?
- Wrong: file size depends on the image’s complexity, not simply on whether it’s vector or raster.
- Correct: vector graphics scale without loss of quality, so they stay sharp when zoomed in or printed at a larger size, unlike raster images.
- Wrong: load time depends on file size and complexity, not simply on vector versus raster format.
- Wrong: Quarto supports both vector and raster image formats.