library(tidyverse)
library(plotly)
library(gapminder)
<- gapminder |>
plot_thing filter(year == 2007) |>
ggplot(aes(x = gdpPercap, y = lifeExp, color = continent)) +
geom_point(aes(text = country)) + # text is a special aesthetic for plotly labels
scale_x_log10()
ggplotly(plot_thing)
Difference-in-differences II
Content for Thursday, March 13, 2025
Readings
This session is a continuation of session 8.
In-class stuff
Here are all the materials we’ll use in class:
LLMs
Text-generation Markov chains with R:
LLMs that work well with code:
- Claude (run by Anthropic, based in the US)
- DeepSeek (run by DeepSeek, based in China—see this and this)
- ChatGPT, but through GitHub Copilot (run by OpenAI, based in the US)
GitHub Copilot:
- General details
- Create a GitHub account
- Optional: Sign up for the GitHub Student Developer Pack
- Use Copilot in the browser
- Use Copilot in Visual Studio Code
- Download and install Visual Studio Code
- Install the GitHub Copilot extension
- Use Copilot in RStudio
- {ellmer} + Ollama
- Roo Code (wild example of a complete website app)
Quarto websites
Resources:
- Creating a website
- Bootswatch themes
- Publishing with Netlify Drop
- Publishing with Quarto Pub
- Publishing with GitHub Pages
Examples:
- This class website :)
- My website (
source
) - Project-specific websites:
- Other websites:
Other Quarto things
- Citations
- Interactivity
- Plotly and
ggplotly()
- Dashboards
- Observable JS + Observable Plot (like ggplot for Javascript)
- Examples:
- Plotly and
ggplotly()
example:
OJS example:
R
This is R code!
# Make the gapminder data available to Observable JS
ojs_define(gapminder = gapminder)
Observable
This is NOT R code! This is Observable JS code!
= Inputs.range(
viewof current_year 1952, 2007],
[value: 1952, step: 5, label: "Year:"}
{
)
// Rotate the data so that it works with OJS
= transpose(gapminder)
gapminder_js
// Filter the data based on the selected year
= gapminder_js.filter(d => d.year == current_year)
gapminder_filtered
// Plot this thing
.plot({
Plotx: {type: "log"},
marks: [
.dot(gapminder_filtered, {
Plotx: "gdpPercap", y: "lifeExp", fill: "continent", r: 6,
channels: {
Country: d => d.country
,
}tip: true
}
)
]} )