Platform
Resources
Pricing
Sign in
Get started
Interactive Info Vis
UW iSchool Course INFO 474: focused on designing and building visualizations to better understand and communicate about pressing issues.
Workspace
Fork
Published
By
Mike Freeman
Edited
Jan 6, 2021
2 forks
2
Insert cell
Insert cell
Insert cell
Insert cell
// Load the protests.csv data (a File Attachment) into a variable
protests
=
FileAttachment
(
"protests.csv"
)
.
csv
(
)
Insert cell
// How many protests are in the dataset?
num_protests
=
REPLACE_ME
Insert cell
Insert cell
// How much information is available about each protest?
num_features
=
REPLACE_ME
Insert cell
Insert cell
Insert cell
// Create an array of the number of attendees in each protest
// (make sure to return a *number* for each element in the array)
num_attendees
=
REPLACE_ME
Insert cell
Insert cell
// What is the lowest number of attendees?
min_attendees
=
REPLACE_ME
Insert cell
Insert cell
// What is the highest number of attendees?
max_attendees
=
REPLACE_ME
Insert cell
Insert cell
// What is the mean number of attendees?
mean_attendees
=
REPLACE_ME
Insert cell
Insert cell
// What is the median number of attendees?
median_attendees
=
REPLACE_ME
Insert cell
Insert cell
// What is the absolute difference between the mean and median number of attendees?
mean_median_diff
=
REPLACE_ME
Insert cell
Insert cell
Insert cell
// Create an array that holds the Location of each protest
locations
=
REPLACE_ME
Insert cell
Insert cell
// How many *unique* locations are in the dataset?
num_locations
=
REPLACE_ME
Insert cell
Insert cell
// How many protests occured in Washington?
// (hint: locations that end with "WA")
num_in_wa
=
REPLACE_ME
Insert cell
Insert cell
// What proportion of protests (number / total) occured in Washington?
prop_in_wa
=
REPLACE_ME
Insert cell
Insert cell
// How many protests occurred in each state?
// hint: use the d3.rollups method to create an *array of arrays*,
// where each one holds the state abbreviation and the number of protests in that state
// https://observablehq.com/@d3/d3-group
num_by_state
=
REPLACE_ME
Insert cell
Insert cell
// What was the highest number of protests that occured in a single state?
highest_in_a_state
=
REPLACE_ME
Insert cell
Insert cell
// Which state (two letter abbreviation) had the highest number of protests?
// hint: use the two variables calculated above
state_most_protests
=
REPLACE_ME
Insert cell
Insert cell
Insert cell
// Create an array that holds the Date of each protest
// You should convert the string in the original dataset to a proper date object using the Date() function
dates
=
REPLACE_ME
Insert cell
Insert cell
// What is the most recent date in the dataset?
most_recent
=
REPLACE_ME
Insert cell
Insert cell
// What is the earliest date in the dataset?
earliest
=
REPLACE_ME
Insert cell
Insert cell
// How many protests occurred in 2020?
// hint: use the getFullYear() method
num_in_2020
=
REPLACE_ME
Insert cell
Insert cell
// How many protests occurred in 2019?
num_in_2019
=
REPLACE_ME
Insert cell
Insert cell
// How many protests occurred in July (of any year)?
// Hint: you can use date.toLocaleDateString("default", { month: "long" }) to get the month name
num_in_july
=
REPLACE_ME
Insert cell
Insert cell
// How many protest occured each month?
// hint: use the d3.rollups method to create an *array of arrays*,
// where each one holds the month name and the number of protests in that month
by_month
=
REPLACE_ME
Insert cell
Insert cell
// Which month had the highest number of protests?
month_most_protests
=
REPLACE_ME
Insert cell
Insert cell
Insert cell
// How many different purposes are listed in the dataset?
// (the number of unique values of the `Event (legacy; see tags)` attribute)
num_purposes
=
REPLACE_ME
Insert cell
Insert cell
// That's quite a few -- if you look at the array, you'll notice
// a common pattern for each purpose. It's listed as:
// SOME_PURPOSE (additiona_detail)
// To get a higher level summary, create an array of `high_level_purposes` by
// extracting *everything before the first parenthesis* in each purpose ("Event (legacy; see tags)")
// You should return an array equal to the length of the protests dataset
high_level_purposes
=
REPLACE_ME
Insert cell
Insert cell
// Which high-level purpose was the most common?
// Hint, you may want to open a JavaScript statement to write multiple lines of code,
// Or try out d3.greatest with d3.rollups
// https://observablehq.com/@d3/d3-least
most_common_purpose
=
REPLACE_ME
Insert cell
Insert cell
Insert cell
import
{
check_answer
,
displayCaution
}
with
{
answers
}
from
"@uw-info474/utilities"
Insert cell
answers
=
await
FileAttachment
(
"answers.json"
)
.
json
(
{
typed
:
true
}
)
Insert cell
new
Date
(
answers
.
earliest
)
Insert cell
d3
=
require
(
"d3"
)
Insert cell
_
=
require
(
"lodash"
)
Insert cell
REPLACE_ME
=
undefined
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
data_structure
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
protests
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_protests
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_features
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
number_of_attendees
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_attendees
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
min_attendees
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
max_attendees
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mean_attendees
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
median_attendees
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mean_median_diff
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
locations_analysis
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
locations
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_locations
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_in_wa
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
prop_in_wa
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_by_state
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
highest_in_a_state
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
state_most_protests
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dates_analysis
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
dates
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
most_recent
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
earliest
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_in_2020
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_in_2019
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_in_july
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
by_month
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
month_most_protests
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
purpose_analysis
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
num_purposes
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
high_level_purposes
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
most_common_purpose
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
answers
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
d3
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
_
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
REPLACE_ME
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML