Public Interest::Data Ethics &
Practice
A new example structure for the Stepping Stones measures, based on Team 5’s suggestions from last week.
What we’ll be doing in class the next three weeks
ggplot breaks up the task of making a graph into a
series of distinct tasks (layering); each task is carried out in code
based on identifiable functions (geom_, scale_, labs, legends, and
more).
Scale functions control the mapping from data to aesthetics and every aesthetic has a default scale.
All scale functions have a common naming scheme:
scale_name of aesthetic_name of scale
scale_y_continuous: assign breaks, labels, limit,
transformationsscale_color_few: assign color palettes from pre-defined
palete (few)scale_fill_manual: assign identified color palettes to
fillScale functions can use functions from the scales package.
label_date(),
label_dollar(), label_percent(),
label_comma(), label_wrap() – control how
labels are printed on the axesThemes control the appearance of a plot – background color, borders, gridlines, text size and font, placement of titles/legends, etc.
Annotations add custom features to a plot, like text or shading
annotate() - not a geom (doesn’t accept mappings/things
that vary) but can use geoms (text, point, segment, etc.) to add text or
rectangles or arrows to a plotgeom_text() - adds text to a plot instead of, or in
addition to, points or lines (e.g., for labeling point values)R Markdown creates dynamic documents by combining markdown (an easy to write plain text format) with embedded R code chunks. When compiled, the code can be evaluated so that the code, its output, and your prose can be included in the final document to make reports reproducible.
The .Rmd file contains
----
----
title: "An incredible project"
subtitle: "Of great significance"
author: "Don't you know who I am?"
date: "2023-02-16"
output:
html_document:
toc: true
toc_depth: 4
toc_float: true
code_folding: hide
----
name (to identify code chunk)echo = TRUE (show code in document)message = FALSE, warning = FALSE (prevent
messages, warnings from appearing)fig.height = X, fig.width = X, fig.cap = "caption below the figure"
(control size of generated figure, presence of figure caption)```{r codechunkname, warning = FALSE, fig.height = 10}
# add code here
```
knitr::opts_chunk$set() (set global options, usually in
first code chunk)You can create tabs in an Rmarkdown document that will be rendered as an html file. This allows readers to view the content of different sections by clicking the tab titles instead of scrolling back and forth on the page.
To turn markdown sections into tabs, add {.tabset} on the right of a header. All of the content in subheaders below this header will be contained in separate tabs. That is, adding the .tabset attribute to a level-2 header (##) will convert all subsequent level-3 headers (###) to tabs.
First go to slack and copy the practice script for today (week5script.R) into your weeklymaterials/scripts folder. Then open an RStudio session using the weeklymaterials.Rproj file.
Which also means if you’d like to add or update annotations for the reading assigned for today, 2/16, you may do so until 2pm on Tuesday 2/23.↩︎