library(jsonlite)
# A JSON array of primitives
json <- '["Mario", "Peach", null, "Bowser"]'
# Simplifies into an atomic vector
fromJSON(json)
[1] "Mario" "Peach" NA "Bowser"
Thank you for peer feedback! I had a lot of fun reading these.
Now online
Due November 13th
GitHub post (used for peer feedback) AND Brightspace
Three Weeks: don’t wait until the very end
Should be less demanding than MP #01 and MP#02
Pay attention to the rubric
Proposal feedback sent by email this afternoon. Please contact if not received.
Next Week: Mid-Term Check-In Presentations
Tentative Topics
Any requests?
Brightspace - Wednesdays at 11:45
Next pre-assignment is November 13th
Thank you for FAQs and (honest) team feedback. Keep it coming!
Change: MW Thursday Zoom OH will be 4:00pm to 5:00pm
No FAQs today. (New topic - data import)
From FiveThirtyEight
Room | Team | Room | Team | |
---|---|---|---|---|
1 | Rat Pack | 6 | Ca$h VZ | |
2 | Subway Surfers | 7 | Listing Legends | |
3 | Chart Toppers | 8 | TDSSG | |
4 | Metro Mindset | 9 | Broker T’s | |
5 | Apple Watch | 10 | EVengers |
Data can be found at https://raw.githubusercontent.com/fivethirtyeight/data/refs/heads/master/candy-power-ranking/candy-data.csv
Read into R
(readr::read_csv
) and make 3 plots:
R
Two topics:
🎃End a bit early for Halloween🎃
From abstrax.io
JSON
:
JavaScript Object Notation
dict
s of dict
s of dict
s) than R
data.frame
sExample:
{
"data": {
"id": 27992,
"title": "A Sunday on La Grande Jatte — 1884",
"image_id": "1adf2696-8489-499b-cad2-821d7fde4b33"
},
"config": {
"iiif_url": "https://www.artic.edu/iiif/2",
}
}
Read JSON in R
with jsonlite
package (alternatives exist)
$utc_offset
[1] "-05:00"
$timezone
[1] "America/New_York"
$day_of_week
[1] 4
$day_of_year
[1] 326
$datetime
[1] "2024-11-21T13:51:03.547245-05:00"
Compare to browser access
download.file
function (url, destfile, method, quiet = FALSE, mode = "w", cacheOK = TRUE,
extra = getOption("download.file.extra"), headers = NULL,
...)
NULL
Basic file download capabilities:
url
: sourcedestfile
: where on your computer to store itmethod
: what software to use in the background to downloadHTTP
ftp
, smtp
, ssh
, …“Low-level” mechanism of internet transfer
R
packages add a friendly UXhttr2
for low-level work (today)HTTP has two stages:
Modern (easy) APIs put most of the behavior in the URL
In Firefox: Right-Click + Inspect
In Chrome: Right-Click + Developer Tools
httr2
httr2
(pronounced “hitter-2”) is low-level manipulation of HTTP.
Pretty simple so far:
example_url()
starts a tiny local web host127.0.0.1
is localhost
Live Demo Time
httr2
RequestsBuild a request:
req_method
req_body_*
req_cookies_set
req_auth_basic
/ req_oauth
Behaviors:
req_cache
req_timeout
Execution:
req_perform
httr2
ResponsesRequest status
resp_status
/ resp_status_desc
Content: - resp_header*
- resp_body_*