Import two related datasets from TidyTuesday Project.
colony <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2022/2022-01-11/colony.csv')
## Rows: 1222 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): months, state
## dbl (8): year, colony_n, colony_max, colony_lost, colony_lost_pct, colony_ad...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
stressor <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/main/data/2022/2022-01-11/stressor.csv')
## Rows: 7332 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): months, state, stressor
## dbl (2): year, stress_pct
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Describe the two datasets:
Data1: Colonies
Data 2: Stressors
set.seed(1234)
colony_small <- colony %>% select(year, state, months, colony_n) %>% sample_n(10)
stressor_small <- stressor %>% select(year,state, months, stressor) %>% sample_n(10)
Describe the resulting data:
How is it different from the original two datasets? * 1 row in this one, 10 in original * Same coloumns from original
colony_small %>% inner_join(stressor_small, by = c("state", "year" ))
## # A tibble: 1 × 6
## year state months.x colony_n months.y stressor
## <dbl> <chr> <chr> <dbl> <chr> <chr>
## 1 2018 Indiana April-June 8000 January-March Pesticides
Describe the resulting data:
How is it different from the original two datasets? * Has N/A Data * More organized
stressor_small %>% left_join(colony_small, by = c("months","state"))
## # A tibble: 10 × 6
## year.x state months stressor year.y colony_n
## <dbl> <chr> <chr> <chr> <dbl> <dbl>
## 1 2017 Iowa October-December Varroa mites NA NA
## 2 2017 Vermont April-June Other pests/parasites NA NA
## 3 2020 Kansas January-March Pesticides NA NA
## 4 2017 Michigan January-March Pesticides NA NA
## 5 2015 West Virginia October-December Other NA NA
## 6 2018 Maine July-September Other pests/parasites NA NA
## 7 2021 Wisconsin January-March Other pests/parasites NA NA
## 8 2018 Missouri October-December Pesticides NA NA
## 9 2018 Indiana January-March Pesticides NA NA
## 10 2016 West Virginia October-December Unknown NA NA
Describe the resulting data:
How is it different from the original two datasets? * N/A data in colony_n (I dont know why) *Removed the .x and .y on the end of year and months
colony_small %>% right_join(stressor_small)
## Joining with `by = join_by(year, state, months)`
## # A tibble: 10 × 5
## year state months colony_n stressor
## <dbl> <chr> <chr> <dbl> <chr>
## 1 2017 Iowa October-December NA Varroa mites
## 2 2017 Vermont April-June NA Other pests/parasites
## 3 2020 Kansas January-March NA Pesticides
## 4 2017 Michigan January-March NA Pesticides
## 5 2015 West Virginia October-December NA Other
## 6 2018 Maine July-September NA Other pests/parasites
## 7 2021 Wisconsin January-March NA Other pests/parasites
## 8 2018 Missouri October-December NA Pesticides
## 9 2018 Indiana January-March NA Pesticides
## 10 2016 West Virginia October-December NA Unknown
Describe the resulting data:
How is it different from the original two datasets? * More rows *N/A data flips at row 11
colony_small %>% full_join(stressor_small)
## Joining with `by = join_by(year, state, months)`
## # A tibble: 20 × 5
## year state months colony_n stressor
## <dbl> <chr> <chr> <dbl> <chr>
## 1 2020 Ohio April-June 15500 <NA>
## 2 2020 Wisconsin October-December 60000 <NA>
## 3 2020 Maine April-June 1600 <NA>
## 4 2018 Indiana April-June 8000 <NA>
## 5 2019 Indiana October-December 17500 <NA>
## 6 2018 Pennsylvania April-June 15500 <NA>
## 7 2019 Virginia October-December 8000 <NA>
## 8 2017 Montana January-March 18500 <NA>
## 9 2019 Florida October-December 270000 <NA>
## 10 2015 California July-September 730000 <NA>
## 11 2017 Iowa October-December NA Varroa mites
## 12 2017 Vermont April-June NA Other pests/parasites
## 13 2020 Kansas January-March NA Pesticides
## 14 2017 Michigan January-March NA Pesticides
## 15 2015 West Virginia October-December NA Other
## 16 2018 Maine July-September NA Other pests/parasites
## 17 2021 Wisconsin January-March NA Other pests/parasites
## 18 2018 Missouri October-December NA Pesticides
## 19 2018 Indiana January-March NA Pesticides
## 20 2016 West Virginia October-December NA Unknown
Describe the resulting data:
How is it different from the original two datasets? * Does not have stressor
colony_small %>% semi_join(stressor_small, by = "months")
## # A tibble: 10 × 4
## year state months colony_n
## <dbl> <chr> <chr> <dbl>
## 1 2020 Ohio April-June 15500
## 2 2020 Wisconsin October-December 60000
## 3 2020 Maine April-June 1600
## 4 2018 Indiana April-June 8000
## 5 2019 Indiana October-December 17500
## 6 2018 Pennsylvania April-June 15500
## 7 2019 Virginia October-December 8000
## 8 2017 Montana January-March 18500
## 9 2019 Florida October-December 270000
## 10 2015 California July-September 730000
Describe the resulting data:
How is it different from the original two datasets? * there is not even a table
colony_small %>% anti_join(stressor_small, by = "months")
## # A tibble: 0 × 4
## # ℹ 4 variables: year <dbl>, state <chr>, months <chr>, colony_n <dbl>