Skip to content

Commit

Permalink
Create practice-solutions.R
Browse files Browse the repository at this point in the history
  • Loading branch information
jhelvy committed Jan 22, 2024
1 parent 212c686 commit 49b562c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions class/1-getting-started/practice-solutions.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 1

# Create values
area_sf <- 47
area_chicago <- 228
area_dc <- 61
pop_sf <- 884
pop_chicago <- 2716
pop_dc <- 694

# Compute densities
dens_sf <- pop_sf / area_sf
dens_chicago <- pop_chicago / area_chicago
dens_dc <- pop_dc / area_dc
dens_sf
dens_chicago
dens_dc

# Compute addition DC population to match SF density
(dens_sf*area_dc) - pop_dc

# 2

w <- TRUE
x <- FALSE
y <- TRUE

! (w == x) & ! (y == x)

! (w & !x) | (y & x)

# For an explanation of why this works, check out this chat:
# https://chat.openai.com/share/f4d2378f-8c9b-449a-afb3-1b4fc8bd30be

0 comments on commit 49b562c

Please sign in to comment.