Lab 03 - Nobel laureates

Jayden Hunt Insert date here

Load packages and data

library(tidyverse) 
nobel <- read_csv("nobel.csv")

Exercises

Exercise 1

dim(nobel)
## [1] 935  26

935 observations 26 variables

Exercise 2

nobel_living <- nobel %>%
  filter(!is.na(country), gender != "org", is.na(died_date))

Exercise 3

nobel_living <- nobel_living %>%
  mutate(
    country_us = if_else(country == "USA", "USA", "Other")
  )
nobel_living_science <- nobel_living %>%
  filter(category %in% c("Physics", "Medicine", "Chemistry", "Economics"))
ggplot(nobel_living_science, aes(x = category, fill = country_us)) +
  geom_bar() + 
  labs(title = "Category of Prize by Country", x = "Category of Prize", y = "Count") + coord_flip() + facet_wrap(~ category)  

Exercise 4

nobel_living_science %>%
  count(born_country)
## # A tibble: 34 × 2
##    born_country     n
##    <chr>        <int>
##  1 Algeria          1
##  2 Australia        3
##  3 Austria          2
##  4 Belgium          1
##  5 Canada           6
##  6 China            6
##  7 Cyprus           1
##  8 Finland          1
##  9 France           8
## 10 Germany         20
## # ℹ 24 more rows

105 born in the USA

Exercise 5

ggplot(nobel_living_science, 
       aes (x = country_us, fill = born_country)) +
  geom_bar() +
  facet_wrap(~category) +
  coord_flip () +
  labs(
    title = "Nobel laureates US affiliation and birth country",
    x = "Where laureates  was based when awarded" ,
    y = "# of laureates",
    fill = "born in")

Exercise 6

nobel_born_count <- nobel_living_science %>%
  mutate(
    born_country_us = if_else(born_country == "USA", "USA", "Other")
  )
nobel_born_count %>% 
  filter(born_country_us == "Other") %>%
  count(born_country)%>% 
  arrange(desc(n)) 
## # A tibble: 33 × 2
##    born_country       n
##    <chr>          <int>
##  1 Germany           20
##  2 Japan             17
##  3 United Kingdom    16
##  4 France             8
##  5 Canada             6
##  6 China              6
##  7 Switzerland        6
##  8 Israel             5
##  9 Norway             4
## 10 Australia          3
## # ℹ 23 more rows

Germany is the most common country