How to write for this blog

news
code
analysis
howto
Author

Ben Baumer

Published

February 8, 2023

This is an example of how to write an article for this blog.

This example is based on work by Brooke Williams, an investigative reporter and associate professor at Boston University. Brooke maintains a public GitHub repository that contains the data she uncovered about money donated by foreign governments to U.S. think tanks. These data motivate the interactive graphic and article published in The New York Times on this issue.

The source code for this article is available on our private GitHub repository. Please review it. You will note that each sentence is written on a new line, and that Markdown formatting is employed to style the text where necessary. Note also how I am using the code-fold and execute YAML options at the top of this Quarto document to control how the rendered output appears. Note that I have specified that code not be echoed when this Quarto document is rendered into a Word document (docx).

Since Brooke’s data is available as a text file in a public GitHub repository, we can load it directly using read_delim(). Note that in this case the file is tab-delimited (\t).

Code
library(tidyverse)
url <- "https://raw.githubusercontent.com/reporterbrooke/think_tanks/master/data"
tanks <- url |>
  read_delim(url, delim = "\t")
glimpse(tanks)
Rows: 599
Columns: 24
$ ID                       <chr> "232", "241", "20337", "245", "243", "244", "…
$ donor_original           <chr> "\"Ministry of Interior Affairs, Albania\"", …
$ donor_clean              <chr> "Ministry of Interior Affairs Albania", "Aust…
$ country_short            <chr> "Albania", "Australia", "Australia", "Austral…
$ country_official         <chr> "Republic of Albania", "Commonwealth of Austr…
$ entity_type              <chr> "Foreign Government", "Foreign Government", "…
$ entity_subtype           <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ donor_level              <chr> NA, "CDI Consortium", NA, "Clients and Granto…
$ tt_EIN                   <chr> "52-0880375", "52-2351337", "52-1640938", "95…
$ tt_UID                   <chr> "52-0880375", "52-2351337", "52-1640938", "95…
$ think_tank               <chr> "Urban Institute", "Center for Global Develop…
$ source                   <chr> "tt website (4/9/14)", "tt website (4/8/14)",…
$ ` min_amount `           <chr> "\" 10,000.00 \"", "\" 30,000.00 \"", NA, "\"…
$ ` max_amount `           <chr> "\" 24,999.00 \"", NA, NA, NA, NA, NA, NA, NA…
$ ` exact_amount `         <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "…
$ ` foreign_amt `          <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ currency_code            <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ `exg_rate(unit-per-USD)` <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ exg_date                 <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ donation_date_notes      <chr> "2012", "As of 4/8/2014. No date provided on …
$ purpose                  <chr> NA, "\"\"\"providing a private forum for offi…
$ notes                    <chr> NA, "Government", NA, "\"Non-U.S. Governments…
$ gift_type                <chr> NA, "Annual Membership Fee", NA, NA, NA, NA, …
$ donor_agency             <chr> NA, NA, NA, "Transport Data Centre", NA, NA, …

Figure 1 is a data graphic created by Brooke’s data. Consider this as an inferior alternative to this one.

Code
tanks |>
  ggplot(aes(x = think_tank, y = country_short)) +
  geom_count(aes(color = after_stat(n))) +
  scale_color_viridis_c() +
  scale_y_discrete(NULL) + 
  guides(size = "none") + 
  theme(
    axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)
  )

Figure 1: Donations to think tanks by country.

Publishing

To publish this article, I made a pull request to this repository. Here are the steps you need to follow:

  • Open a new branch. The easiest (but not the only) way to do this is by running usethis::pr_init("name-of-new-branch"). Please read the documentation for these functions if necessary.
  • Copy this Quarto file (or another one) to a new folder in the posts/ directory. Use dashes instead of spaces in the name of the new directory!
  • Write your article.
  • If necessary (it generally shouldn’t be), add any other files you need to this directory.
  • Commit repeatedly until you are done.
  • Push and open your pull request. The easiest way to do this is using usethis::pr_push().
  • Follow the progress of your pull request on GitHub.

Please note that you first need to set up a GitHub token. Read the instructions and use the usethis::git_sitrep() function.