1  Intro

📜The narrative around the code is as important as the code itself📜

1.1 Code Access

The code you use to produce analytical outcomes and summaries is the lifeblood of your work as a data science practitioner.

Literate programming platforms provide unique tools for code access that are enabled at the document/presentation-level, if desired. For example, you may have collaborators who wish to inspect code or you may be documenting your code to provide full transparency for the process(es) used to conduct an analysis.

1.1.1 Code sharing

The code represented in Listing 1.1 (and all example pieces of code) can be copied by activating the clipboard option in the upper-right hand corner of the code chunk.

Tip

Code can always be copied onto your personal computer via the clipboard icon: .

Listing 1.1: Addition within R
1 + 1                                    

For more complex bits of analysis, hidden annotations are available (the reader can further access notes/assistance by hovering over the circled numbers):

library(psych)
data(bfi)

bfi$jibberish <- rowMeans(bfi[1:10], na.rm=TRUE)
bfi$gobbleyjook <- rowMeans(bfi[11:20], na.rm=TRUE)
1
The psych package contains example data that we can access.
2
This gives us access to the bfi dataset that contains personality item responses.
3
We make 2 scale scores, jibberish and gobbleyjook. The $ notation indicates that these scale scores will be appended to the bfi dataframe.

The entire code block can also be hidden unless asked-for. These features permit reviewers/collaborators of different need or curiosity to access source code on an as-needed basis:

Code
library(psych)
data(bfi)

bfi$jibberish <- rowMeans(bfi[1:10], na.rm=TRUE)
bfi$gobbleyjook <- rowMeans(bfi[11:20], na.rm=TRUE)
1
The psych package contains example data that we can access.
2
This gives us access to the bfi dataset that contains personality item responses.
3
We make 2 scale scores, jibberish and gobbleyjook. The $ notation indicates that these scale scores will be appended to the bfi dataframe.

1.2 Data Summaries

Summaries of your analyses are typically the most important (to external review) aspect of your work. These are the illustrations of your story. The primary principles of analyses within a literate programming framework are:

  1. Preserve the source data
  2. Document all manipulations

Below you can find a few data presentation enhancements that are enabled via literate programming platforms.

1.2.1 Data vizualizations

Figure 1.1 demonstrates lightbox capabilities for images embedded within literate programming reports, whereby “clicking” isolates the image for closer inspection. This is useful for images that contain fine detail, user devices that may not display optimally, drawing focus to specific data features, and increasing accessibility for visually impaired viewers.

Figure 1.2 highlights standard interactive components for graphical representations of data. These interactive components are fully accessible within the source document/presentation.

Figure 1.2: Example interactive plot

Figure 1.3 is another example of interactivity - a map such as this can help reinforce viewer concepts such as representativeness within normative samples (e.g., where the data “came from” and who the data represents). The audience can get a sense of geographic representation by “zooming out” or “zooming in” and verifying that only North America is represented within this dataset.

Figure 1.3: Example normative representation by geographic location.

1.2.2 Informational Tutorials

Video 1.1 shows another example - videos can be pulled from external sites (like this tutorial on parameterized reporting within Quarto) or can present locally produced video files.

Video 1.1: Parameterized reports