diff --git a/.Rhistory b/.Rhistory index 56b2fa6..bd9c34f 100644 --- a/.Rhistory +++ b/.Rhistory @@ -1,512 +1,512 @@ -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( -second_plant = -case_when( -second_plant == "Climbing Bean" ~ "Beans (climbing)", -second_plant == "Climbing Beans" ~ "Beans (climbing)", -second_plant == "Beans" ~ "Beans (all)", -second_plant == "Beans (most)" ~ "Beans (all)", -second_plant == "Bush Beans" ~ "Beans (bush)", -second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +raw_wldata <- +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( plant = -case_when( -plant == "Climbing Beans" ~ "Beans (climbing)", -plant == "Bush Beans" ~ "Beans (bush)", -plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter( -plant != "Garlic" & -second_plant != "Peas" & -relationship != "Companions") -clean_data2 <- -raw_wldata %>% -filter(is.na(comment)) %>% -select(-comment) %>% -filter(!str_detect(plant, "Fruit Trees") & -!str_detect(second_plant, "Fruit Trees") & -!str_detect(plant, "Apple") & -!str_detect(second_plant, "Apple") & -!str_detect(plant, "Apricot") & -!str_detect(second_plant, "Apricot") & -!str_detect(plant, "Cherry") & -!str_detect(second_plant, "Cherry") & -!str_detect(plant, "Grape") & -!str_detect(second_plant, "Grape") & -!str_detect(second_plant, "Blackberries") & -!str_detect(plant, "Silverbeet") & -!str_detect(second_plant, "Silverbeet") & -!str_detect(plant, "Roses") & -!str_detect(second_plant, "Roses") & -!str_detect(second_plant, "Raspberry") & -!str_detect(second_plant, "Rose") & -!str_detect(plant, "Mulberry") & -!str_detect(second_plant, "Mulberry") & -!str_detect(plant, "Broad Beans") & -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( -second_plant = -case_when( -second_plant == "Climbing Bean" ~ "Beans (climbing)", -second_plant == "Climbing Beans" ~ "Beans (climbing)", -second_plant == "Beans" ~ "Beans (all)", -second_plant == "Beans (most)" ~ "Beans (all)", -second_plant == "Bush Beans" ~ "Beans (bush)", -second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) |> +dplyr::filter(is.na(dlete)) |> +dplyr::select(-dlete) |> +dplyr::rename(second_plant = X1) |> +dplyr::relocate(plant, .before = "second_plant") +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( plant = -case_when( -plant == "Climbing Beans" ~ "Beans (climbing)", -plant == "Bush Beans" ~ "Beans (bush)", -plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter( -plant != "Garlic", -second_plant != "Peas", -relationship != "Companions") -clean_data2 <- -raw_wldata %>% -filter(is.na(comment)) %>% -select(-comment) %>% -filter(!str_detect(plant, "Fruit Trees") & -!str_detect(second_plant, "Fruit Trees") & -!str_detect(plant, "Apple") & -!str_detect(second_plant, "Apple") & -!str_detect(plant, "Apricot") & -!str_detect(second_plant, "Apricot") & -!str_detect(plant, "Cherry") & -!str_detect(second_plant, "Cherry") & -!str_detect(plant, "Grape") & -!str_detect(second_plant, "Grape") & -!str_detect(second_plant, "Blackberries") & -!str_detect(plant, "Silverbeet") & -!str_detect(second_plant, "Silverbeet") & -!str_detect(plant, "Roses") & -!str_detect(second_plant, "Roses") & -!str_detect(second_plant, "Raspberry") & -!str_detect(second_plant, "Rose") & -!str_detect(plant, "Mulberry") & -!str_detect(second_plant, "Mulberry") & -!str_detect(plant, "Broad Beans") & -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( -second_plant = -case_when( -second_plant == "Climbing Bean" ~ "Beans (climbing)", -second_plant == "Climbing Beans" ~ "Beans (climbing)", -second_plant == "Beans" ~ "Beans (all)", -second_plant == "Beans (most)" ~ "Beans (all)", -second_plant == "Bush Beans" ~ "Beans (bush)", -second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( plant = -case_when( -plant == "Climbing Beans" ~ "Beans (climbing)", -plant == "Bush Beans" ~ "Beans (bush)", -plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!( plant == "Garlic" & second_plant != "Peas" & relationship != "Companions")) -clean_data2 <- -raw_wldata %>% -filter(is.na(comment)) %>% -select(-comment) %>% -filter(!str_detect(plant, "Fruit Trees") & -!str_detect(second_plant, "Fruit Trees") & -!str_detect(plant, "Apple") & -!str_detect(second_plant, "Apple") & -!str_detect(plant, "Apricot") & -!str_detect(second_plant, "Apricot") & -!str_detect(plant, "Cherry") & -!str_detect(second_plant, "Cherry") & -!str_detect(plant, "Grape") & -!str_detect(second_plant, "Grape") & -!str_detect(second_plant, "Blackberries") & -!str_detect(plant, "Silverbeet") & -!str_detect(second_plant, "Silverbeet") & -!str_detect(plant, "Roses") & -!str_detect(second_plant, "Roses") & -!str_detect(second_plant, "Raspberry") & -!str_detect(second_plant, "Rose") & -!str_detect(plant, "Mulberry") & -!str_detect(second_plant, "Mulberry") & -!str_detect(plant, "Broad Beans") & -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( -second_plant = -case_when( -second_plant == "Climbing Bean" ~ "Beans (climbing)", -second_plant == "Climbing Beans" ~ "Beans (climbing)", -second_plant == "Beans" ~ "Beans (all)", -second_plant == "Beans (most)" ~ "Beans (all)", -second_plant == "Bush Beans" ~ "Beans (bush)", -second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( plant = -case_when( -plant == "Climbing Beans" ~ "Beans (climbing)", -plant == "Bush Beans" ~ "Beans (bush)", -plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!( plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) -clean_data2 <- -raw_wldata %>% -filter(is.na(comment)) %>% -select(-comment) %>% -filter(!str_detect(plant, "Fruit Trees") & -!str_detect(second_plant, "Fruit Trees") & -!str_detect(plant, "Apple") & -!str_detect(second_plant, "Apple") & -!str_detect(plant, "Apricot") & -!str_detect(second_plant, "Apricot") & -!str_detect(plant, "Cherry") & -!str_detect(second_plant, "Cherry") & -!str_detect(plant, "Grape") & -!str_detect(second_plant, "Grape") & -!str_detect(second_plant, "Blackberries") & -!str_detect(plant, "Silverbeet") & -!str_detect(second_plant, "Silverbeet") & -!str_detect(plant, "Roses") & -!str_detect(second_plant, "Roses") & -!str_detect(second_plant, "Raspberry") & -!str_detect(second_plant, "Rose") & -!str_detect(plant, "Mulberry") & -!str_detect(second_plant, "Mulberry") & -!str_detect(plant, "Broad Beans") & -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( +plant = +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) |> +dplyr::filter(is.na(dlete)) |> +dplyr::select(-dlete) +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( +plant = +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) |> +dplyr::filter(is.na(dlete)) |> +dplyr::select(-dlete) |> +dplyr::rename(second_plant = X1) |> +dplyr::relocate(plant, .before = "second_plant") +raw_wldata |> +dplyr::filter(!is.na(comment)) |> +dplyr::select(-c("second_plant", "relationship")) +comments <- +raw_wldata |> +dplyr::filter(!is.na(comment)) |> +dplyr::select(-c("second_plant", "relationship")) +raw_wldata |> +dplyr::filter(is.na(comment)) |> +dplyr::select(-comment) +# Read in raw data from Walden Labs +# https://waldenlabs.com/the-ultimate-companion-planting-guide-chart/ +raw_wldata <- +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( +plant = +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) |> +dplyr::filter(is.na(dlete)) |> +dplyr::select(-dlete) |> +dplyr::rename(second_plant = X1) |> +dplyr::relocate(plant, .before = "second_plant") +# Define plants unwanted in final output +excluded <- +c("Fruit Trees", "Apple", "Apricot", "Cherry", "Grape", "Blackberries", +"Silverbeet", "Roses", "Rose", "Raspberry", "Mulberry", "Broad Beans", +"All Plants", "Most Plants", "Most Herbs", "None") +clean_data <- +raw_wldata |> +dplyr::filter(is.na(comment)) |> +dplyr::select(-comment) |> +dplyr::filter( +!plant %in% excluded & !second_plant %in% excluded & +!stringr::str_detect(second_plant, "\\>")) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "Aspargus", "Asparagus"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "Brocolli", "Broccoli"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Pepper$", "Peppers"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Beet$", "Beets"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Carrot$", "Carrots"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Chive$", "Chives"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Cucumber$", "Cucumbers"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Leek$", "Leeks"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Marigold$", "Marigolds"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Melon$", "Melons"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Parsnip$", "Parsnips"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Radish$", "Radishes"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Tomato$", "Tomatoes"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Pumpkin$", "Pumpkins"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Soybean$", "Soybeans"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Potato$", "Potatoes"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Sunflower$", "Sunflowers"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Strawberry$", "Strawberries"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Nasturtium$", "Nasturtiums"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Onion$", "Onions"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Turnip$", "Turnips"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Chard$", "Swiss Chard"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Sage and many other herbs$", "Sage"))) |> +dplyr::mutate( second_plant = -case_when( +dplyr::case_when( second_plant == "Climbing Bean" ~ "Beans (climbing)", second_plant == "Climbing Beans" ~ "Beans (climbing)", second_plant == "Beans" ~ "Beans (all)", second_plant == "Beans (most)" ~ "Beans (all)", second_plant == "Bush Beans" ~ "Beans (bush)", second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +TRUE ~ second_plant)) |> +dplyr::mutate( plant = -case_when( +dplyr::case_when( plant == "Climbing Beans" ~ "Beans (climbing)", plant == "Bush Beans" ~ "Beans (bush)", plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!( plant != "Garlic" & second_plant != "Peas" & relationship != "Companions")) -clean_data %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!( plant != "Garlic" & second_plant != "Peas" & relationship != "Companions")) -clean_data %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(( plant != "Garlic" & second_plant != "Peas" & relationship != "Companions")) -clean_data %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(plant != "Garlic" & second_plant != "Peas" & relationship != "Companions") -clean_data %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(plant != "Garlic" && second_plant != "Peas" && relationship != "Companions") -clean_data %>% -# Post-hoc fix to remove garlic listed as peas companion -filter((plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) -clean_data %>% +TRUE ~ plant)) # Post-hoc fix to remove garlic listed as peas companion -filter(!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) clean_data2 <- -raw_wldata %>% -filter(is.na(comment)) %>% -select(-comment) %>% -filter(!str_detect(plant, "Fruit Trees") & -!str_detect(second_plant, "Fruit Trees") & -!str_detect(plant, "Apple") & -!str_detect(second_plant, "Apple") & -!str_detect(plant, "Apricot") & -!str_detect(second_plant, "Apricot") & -!str_detect(plant, "Cherry") & -!str_detect(second_plant, "Cherry") & -!str_detect(plant, "Grape") & -!str_detect(second_plant, "Grape") & -!str_detect(second_plant, "Blackberries") & -!str_detect(plant, "Silverbeet") & -!str_detect(second_plant, "Silverbeet") & -!str_detect(plant, "Roses") & -!str_detect(second_plant, "Roses") & -!str_detect(second_plant, "Raspberry") & -!str_detect(second_plant, "Rose") & -!str_detect(plant, "Mulberry") & -!str_detect(second_plant, "Mulberry") & -!str_detect(plant, "Broad Beans") & -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( +clean_data |> +dplyr::filter( +!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) +View(clean_data2) +rm(clean_data2) +# Read in raw data from Walden Labs +# https://waldenlabs.com/the-ultimate-companion-planting-guide-chart/ +raw_wldata <- +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( +plant = +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) |> +dplyr::filter(is.na(dlete)) |> +dplyr::select(-dlete) |> +dplyr::rename(second_plant = X1) |> +dplyr::relocate(plant, .before = "second_plant") +# Define plants unwanted in final output +excluded <- +c("Fruit Trees", "Apple", "Apricot", "Cherry", "Grape", "Blackberries", +"Silverbeet", "Roses", "Rose", "Raspberry", "Mulberry", "Broad Beans", +"All Plants", "Most Plants", "Most Herbs", "None") +clean_data <- +raw_wldata |> +dplyr::filter(is.na(comment)) |> +dplyr::select(-comment) |> +dplyr::filter( +!plant %in% excluded & !second_plant %in% excluded & +!stringr::str_detect(second_plant, "\\>")) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "Aspargus", "Asparagus"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "Brocolli", "Broccoli"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Pepper$", "Peppers"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Beet$", "Beets"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Carrot$", "Carrots"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Chive$", "Chives"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Cucumber$", "Cucumbers"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Leek$", "Leeks"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Marigold$", "Marigolds"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Melon$", "Melons"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Parsnip$", "Parsnips"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Radish$", "Radishes"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Tomato$", "Tomatoes"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Pumpkin$", "Pumpkins"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Soybean$", "Soybeans"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Potato$", "Potatoes"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Sunflower$", "Sunflowers"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Strawberry$", "Strawberries"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Nasturtium$", "Nasturtiums"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Onion$", "Onions"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Turnip$", "Turnips"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Chard$", "Swiss Chard"))) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "^Sage and many other herbs$", "Sage"))) |> +dplyr::mutate( second_plant = -case_when( +dplyr::case_when( second_plant == "Climbing Bean" ~ "Beans (climbing)", second_plant == "Climbing Beans" ~ "Beans (climbing)", second_plant == "Beans" ~ "Beans (all)", second_plant == "Beans (most)" ~ "Beans (all)", second_plant == "Bush Beans" ~ "Beans (bush)", second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +TRUE ~ second_plant)) |> +dplyr::mutate( plant = -case_when( +dplyr::case_when( plant == "Climbing Beans" ~ "Beans (climbing)", plant == "Bush Beans" ~ "Beans (bush)", plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) -clean_data %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) -clean_data2 <- -raw_wldata %>% -filter(is.na(comment)) %>% -select(-comment) %>% -filter(!str_detect(plant, "Fruit Trees") & -!str_detect(second_plant, "Fruit Trees") & -!str_detect(plant, "Apple") & -!str_detect(second_plant, "Apple") & -!str_detect(plant, "Apricot") & -!str_detect(second_plant, "Apricot") & -!str_detect(plant, "Cherry") & -!str_detect(second_plant, "Cherry") & -!str_detect(plant, "Grape") & -!str_detect(second_plant, "Grape") & -!str_detect(second_plant, "Blackberries") & -!str_detect(plant, "Silverbeet") & -!str_detect(second_plant, "Silverbeet") & -!str_detect(plant, "Roses") & -!str_detect(second_plant, "Roses") & -!str_detect(second_plant, "Raspberry") & -!str_detect(second_plant, "Rose") & -!str_detect(plant, "Mulberry") & -!str_detect(second_plant, "Mulberry") & -!str_detect(plant, "Broad Beans") & -!str_detect(second_plant, "\\>") & -!str_detect(second_plant, "All Plants") & -!str_detect(second_plant, "Most Plants") & -!str_detect(second_plant, "Most Herbs") & -!str_detect(second_plant, "None")) %>% -mutate(across(contains("plant"), ~str_replace(., "Aspargus", "Asparagus"))) %>% -mutate(across(contains("plant"), ~str_replace(., "Brocolli", "Broccoli"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pepper$", "Peppers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Beet$", "Beets"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Brussels Sprout$", "Brussels Sprouts"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Carrot$", "Carrots"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chive$", "Chives"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Cucumber$", "Cucumbers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Leek$", "Leeks"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Marigold$", "Marigolds"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Melon$", "Melons"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Parsnip$", "Parsnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Radish$", "Radishes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Tomato$", "Tomatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Pumpkin$", "Pumpkins"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Soybean$", "Soybeans"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Potato$", "Potatoes"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sunflower$", "Sunflowers"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Strawberry$", "Strawberries"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Nasturtium$", "Nasturtiums"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Onion$", "Onions"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Turnip$", "Turnips"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Chard$", "Swiss Chard"))) %>% -mutate(across(contains("plant"), ~str_replace(., "^Sage and many other herbs$", "Sage"))) %>% -mutate( +TRUE ~ plant)) |> +# Remove error: garlic listed as peas companion +dplyr::filter( +!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) +raw_wldata +raw_wldata |> +dplyr::filter(is.na(comment)) +raw_wldata |> +dplyr::filter(!is.na(comment)) +raw_wldata |> +dplyr::filter(is.na(comment)) |> +dplyr::select(-comment) |> +dplyr::filter( +!plant %in% excluded & !second_plant %in% excluded & +!stringr::str_detect(second_plant, "\\>")) +raw_wldata |> +dplyr::filter(is.na(comment)) |> +dplyr::select(-comment) |> +dplyr::filter( +!plant %in% excluded & !second_plant %in% excluded & +!stringr::str_detect(second_plant, "\\>")) |> +dplyr::mutate(dplyr::across(dplyr::contains("plant"), ~stringr::str_replace(., "Aspargus", "Asparagus"))) +clean_data +clean_data |> +dplyr::mutate( +key = +paste0(stringr::str_sort(c(plant, second_plant)), collapse = ""), +key2 = +paste0(c(plant, second_plant), collapse = "")) +clean_data |> +dplyr::rowwise() |> +dplyr::mutate( +key = +paste0(stringr::str_sort(c(plant, second_plant)), collapse = ""), +key2 = +paste0(c(plant, second_plant), collapse = "")) +clean_data |> +dplyr::rowwise() |> +dplyr::mutate( +key = +paste0(stringr::str_sort(c(plant, second_plant)), collapse = "") +) |> +group_by(key) |> +filter(n() != 2) +clean_data |> +dplyr::rowwise() |> +dplyr::mutate( +key = +paste0(stringr::str_sort(c(plant, second_plant)), collapse = "") +) |> +dplyr::group_by(key) |> +dplyr::filter(n() != 2) +clean_data |> +dplyr::rowwise() |> +dplyr::mutate( +key = +paste0(stringr::str_sort(c(plant, second_plant)), collapse = "") +) |> +dplyr::group_by(key) |> +dplyr::filter(dplyr::n() != 2) +clean_data |> dplyr::filter(plant == "Basil") |> dplyr::pull(second_plant) +clean_data |> dplyr::filter(plant == "Chamomile") |> dplyr::pull(second_plant) +# Read in raw data from Walden Labs +# https://waldenlabs.com/the-ultimate-companion-planting-guide-chart/ +raw_wldata <- +readr::read_csv("raw_data/companion_planting_raw.csv", col_names = F) |> +dplyr::mutate( +plant = +ifelse( +stringr::str_detect(X1, "\\stop"), +stringr::str_extract(X1, ".+(?=\\stop$)"), +NA), +relationship = +dplyr::case_when( +stringr::str_detect(X1, "Companions") ~ "Companions", +stringr::str_detect(X1, "Antagonists") ~ "Antagonists", +TRUE ~ NA_character_), +comment = ifelse(X1 == "Comments", dplyr::lead(X1), NA), +dlete = ifelse(dplyr::lag(X1) == "Comments", "x", NA)) |> +tidyr::fill(plant, relationship) |> +dplyr::filter( +!stringr::str_detect(X1, "\\stop") & +!stringr::str_detect(X1, "Companions") & +!stringr::str_detect(X1, "Antagonists")) |> +dplyr::filter(is.na(dlete)) |> +dplyr::select(-dlete) |> +dplyr::rename(second_plant = X1) |> +dplyr::relocate(plant, .before = "second_plant") +# Define plants unwanted in final output +excluded <- +c("Fruit Trees", "Apple", "Apricot", "Cherry", "Grape", "Blackberries", +"Silverbeet", "Roses", "Rose", "Raspberry", "Mulberry", "Broad Beans", +"All Plants", "Most Plants", "Most Herbs", "None") +# Clean up raw data +clean_data <- +raw_wldata |> +dplyr::filter(is.na(comment)) |> +dplyr::select(-comment) |> +# Filter out excluded plants +dplyr::filter( +!plant %in% excluded & !second_plant %in% excluded & +!stringr::str_detect(second_plant, "\\>")) |> +# Spelling fixes +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "Aspargus", "Asparagus") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "Brocolli", "Broccoli") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Pepper$", "Peppers") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Beet$", "Beets") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Brussels Sprout$", "Brussels Sprouts") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Carrot$", "Carrots") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Chive$", "Chives") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Cucumber$", "Cucumbers") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Leek$", "Leeks") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Marigold$", "Marigolds") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Melon$", "Melons") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Parsnip$", "Parsnips") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Radish$", "Radishes") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Tomato$", "Tomatoes") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Pumpkin$", "Pumpkins") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Soybean$", "Soybeans") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Potato$", "Potatoes") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Sunflower$", "Sunflowers") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Strawberry$", "Strawberries") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Nasturtium$", "Nasturtiums") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Onion$", "Onions") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Turnip$", "Turnips") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Chard$", "Swiss Chard") +)) |> +dplyr::mutate(dplyr::across( +dplyr::contains("plant"), +~ stringr::str_replace(., "^Sage and many other herbs$", "Sage") +)) |> +dplyr::mutate( second_plant = -case_when( +dplyr::case_when( second_plant == "Climbing Bean" ~ "Beans (climbing)", second_plant == "Climbing Beans" ~ "Beans (climbing)", second_plant == "Beans" ~ "Beans (all)", second_plant == "Beans (most)" ~ "Beans (all)", second_plant == "Bush Beans" ~ "Beans (bush)", second_plant == "Beans (Bush & Climbing)" ~ "Beans (all)", -TRUE ~ second_plant)) %>% -mutate( +TRUE ~ second_plant)) |> +dplyr::mutate( plant = -case_when( +dplyr::case_when( plant == "Climbing Beans" ~ "Beans (climbing)", plant == "Bush Beans" ~ "Beans (bush)", plant == "Beans" ~ "Beans (all)", -TRUE ~ plant)) %>% -# Post-hoc fix to remove garlic listed as peas companion -filter(!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) -# Post-hoc fix to remove garlic listed as peas companion -clean_data2 <- -clean_data %>% -filter(!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) -write.csv(clean_data2, "clean_data/plant_relationships.csv", row.names = F) +TRUE ~ plant)) |> +# Remove error: garlic listed as peas companion +dplyr::filter( +!(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) +# Write out csv for shiny app +write.csv(clean_data, "clean_data/plant_relationships.csv", row.names = F) +runApp('ui.R') diff --git a/clean_data/plant_relationships.csv b/clean_data/plant_relationships.csv index d1e8d2e..dcb73d4 100644 --- a/clean_data/plant_relationships.csv +++ b/clean_data/plant_relationships.csv @@ -174,7 +174,6 @@ "Carrots","Tomatoes","Companions" "Carrots","Beans (all)","Companions" "Carrots","Leeks","Companions" -"Carrots","Rosemary","Companions" "Carrots","Sage","Companions" "Carrots","Peas","Companions" "Carrots","Dill","Antagonists" @@ -197,7 +196,6 @@ "Celery","Beans (bush)","Companions" "Celery","Cauliflower","Companions" "Celery","Broccoli","Companions" -"Celery","Cauliflower","Companions" "Celery","Cabbage","Companions" "Celery","Corn","Antagonists" "Celery","Potatoes","Antagonists" @@ -232,7 +230,6 @@ "Corn","Dill","Companions" "Corn","Peas","Companions" "Corn","Parsley","Companions" -"Corn","Potatoes","Companions" "Corn","Mustard","Companions" "Corn","Pumpkins","Companions" "Corn","Melons","Companions" @@ -310,7 +307,6 @@ "Grape Vine","Chives","Companions" "Grape Vine","Mustard","Companions" "Grape Vine","Oregano","Companions" -"Grape Vine","Peas","Companions" "Grape Vine","Geraniums","Companions" "Grape Vine","Cabbage","Antagonists" "Grape Vine","Garlic","Antagonists" @@ -458,7 +454,6 @@ "Potatoes","Marigolds","Companions" "Potatoes","Peas","Companions" "Potatoes","Broccoli","Companions" -"Potatoes","Corn","Companions" "Potatoes","Onions","Companions" "Potatoes","Garlic","Companions" "Potatoes","Clover","Companions" @@ -492,7 +487,6 @@ "Rosemary","Beans (all)","Companions" "Rosemary","Sage","Companions" "Rosemary","Carrots","Companions" -"Rosemary","Sage","Companions" "Rosemary","Broccoli","Companions" "Rosemary","Tomatoes","Antagonists" "Rue","Lavender","Companions" @@ -529,7 +523,6 @@ "Spinach","Celery","Companions" "Spinach","Cauliflower","Companions" "Spinach","Eggplant","Companions" -"Spinach","Peas","Companions" "Spinach","Beans (all)","Companions" "Spinach","Broccoli","Companions" "Squash","Borage","Companions" @@ -634,3 +627,445 @@ "Zucchini","Marjoram","Companions" "Zucchini","Parsnips","Companions" "Zucchini","Potatoes","Antagonists" +"Basil","Asparagus","Companions" +"Parsley","Asparagus","Companions" +"Dill","Asparagus","Companions" +"Coriander","Asparagus","Companions" +"Comfrey","Asparagus","Companions" +"Nasturtiums","Asparagus","Companions" +"Onions","Asparagus","Antagonists" +"Potatoes","Asparagus","Antagonists" +"Gladiolas","Asparagus","Antagonists" +"Garlic","Asparagus","Antagonists" +"Chamomile","Basil","Companions" +"Anise","Basil","Companions" +"Peppers","Basil","Companions" +"Oregano","Basil","Companions" +"Asparagus","Basil","Companions" +"Petunias","Basil","Companions" +"Beets","Beans (all)","Companions" +"Cucumbers","Beans (all)","Companions" +"Carrots","Beans (all)","Companions" +"Lettuce","Beans (all)","Companions" +"Okra","Beans (all)","Companions" +"Potatoes","Beans (all)","Companions" +"Dill","Beans (all)","Companions" +"Cabbage","Beans (all)","Companions" +"Swiss Chard","Beans (all)","Companions" +"Eggplant","Beans (all)","Companions" +"Peas","Beans (all)","Companions" +"Broccoli","Beans (all)","Companions" +"Cauliflower","Beans (all)","Companions" +"Corn","Beans (all)","Companions" +"Grape Vine","Beans (all)","Companions" +"Savory","Beans (all)","Companions" +"Borage","Beans (all)","Companions" +"Marigolds","Beans (all)","Companions" +"Radishes","Beans (all)","Companions" +"Mint","Beans (all)","Companions" +"Rosemary","Beans (all)","Companions" +"Onions","Beans (all)","Companions" +"Squash","Beans (all)","Companions" +"Tomatoes","Beans (all)","Antagonists" +"Peppers","Beans (all)","Antagonists" +"Alliums","Beans (all)","Antagonists" +"Cucumbers","Beans (bush)","Companions" +"Soybeans","Beans (bush)","Companions" +"Grains","Beans (bush)","Companions" +"Beets","Beans (bush)","Companions" +"Cabbage","Beans (bush)","Companions" +"Carrots","Beans (bush)","Companions" +"Cauliflower","Beans (bush)","Companions" +"Corn","Beans (bush)","Companions" +"Marigolds","Beans (bush)","Companions" +"Potatoes","Beans (bush)","Companions" +"Savory","Beans (bush)","Companions" +"Soybeans","Beans (bush)","Antagonists" +"Alfalfa","Beans (bush)","Antagonists" +"Fennel","Beans (bush)","Antagonists" +"Garlic","Beans (bush)","Antagonists" +"Leeks","Beans (bush)","Antagonists" +"Onions","Beans (bush)","Antagonists" +"Shallot","Beans (bush)","Antagonists" +"Cabbage","Beans (climbing)","Companions" +"Radishes","Beans (climbing)","Companions" +"Marigolds","Beans (climbing)","Companions" +"Potatoes","Beans (climbing)","Companions" +"Beets","Beans (climbing)","Antagonists" +"Fennel","Beans (climbing)","Antagonists" +"Cauliflower","Beans (climbing)","Antagonists" +"Kohlrabi","Beans (climbing)","Antagonists" +"Garlic","Beans (climbing)","Antagonists" +"Onions","Beans (climbing)","Antagonists" +"Shallot","Beans (climbing)","Antagonists" +"Leeks","Beans (climbing)","Antagonists" +"Onions","Beets","Companions" +"Shallot","Beets","Companions" +"Broccoli","Beets","Companions" +"Cauliflower","Beets","Companions" +"Beans (bush)","Beets","Companions" +"Swiss Chard","Beets","Companions" +"Cabbage","Beets","Companions" +"Mint","Beets","Companions" +"Beans (climbing)","Beets","Antagonists" +"Tomatoes","Beets","Antagonists" +"Mustard","Beets","Antagonists" +"Beans (all)","Borage","Companions" +"Cucumbers","Borage","Companions" +"Cabbage","Borage","Companions" +">","Borage","Antagonists" +"Beets","Broccoli","Companions" +"Turnips","Broccoli","Companions" +"Onions","Broccoli","Companions" +"Tomatoes","Broccoli","Companions" +"Carrots","Broccoli","Companions" +"Mint","Broccoli","Companions" +"Nasturtiums","Broccoli","Companions" +"Thyme","Broccoli","Companions" +"Peppers","Broccoli","Antagonists" +"Thyme","Brussels Sprouts","Companions" +"Beans (all)","Brussels Sprouts","Companions" +"Carrots","Brussels Sprouts","Companions" +"Chamomile","Brussels Sprouts","Companions" +"Dill","Brussels Sprouts","Companions" +"Marigolds","Brussels Sprouts","Companions" +"Mint","Brussels Sprouts","Companions" +"Onions","Brussels Sprouts","Companions" +"Nasturtiums","Brussels Sprouts","Companions" +"Rosemary","Brussels Sprouts","Companions" +"Strawberries","Brussels Sprouts","Antagonists" +"Beans (all)","Cabbages","Companions" +"Chamomile","Cabbages","Companions" +"Tomatoes","Cabbages","Companions" +"Celery","Cabbages","Companions" +"Marigolds","Cabbages","Companions" +"Nasturtiums","Cabbages","Companions" +"Dill","Cabbages","Companions" +"Coriander","Cabbages","Companions" +"Onions","Cabbages","Companions" +"Beets","Cabbages","Companions" +"Mint","Cabbages","Companions" +"Rosemary","Cabbages","Companions" +"Sage","Cabbages","Companions" +"Thyme","Cabbages","Companions" +"Lettuce","Cabbages","Companions" +"Garlic","Cabbages","Companions" +"Broccoli","Cabbages","Companions" +"Brussels Sprouts","Cabbages","Companions" +"Swiss Chard","Cabbages","Companions" +"Spinach","Cabbages","Companions" +"Grape Vine","Cabbages","Antagonists" +"Rue","Cabbages","Antagonists" +"Strawberries","Cabbages","Antagonists" +"Chamomile","Cantaloupe","Companions" +"Savory","Cantaloupe","Companions" +"Corn","Cantaloupe","Companions" +"Cauliflower","Chamomile","Companions" +"Onions","Chamomile","Companions" +"Cabbage","Chamomile","Companions" +"Mint","Chamomile","Antagonists" +"Rosemary","Carrots","Companions" +"Onions","Carrots","Companions" +"Lettuce","Carrots","Companions" +"Garlic","Carrots","Companions" +"Shallot","Carrots","Companions" +"Chives","Carrots","Companions" +"Tomatoes","Carrots","Companions" +"Beans (all)","Carrots","Companions" +"Leeks","Carrots","Companions" +"Sage","Carrots","Companions" +"Peas","Carrots","Companions" +"Dill","Carrots","Antagonists" +"Parsnips","Carrots","Antagonists" +"Radishes","Carrots","Antagonists" +"Sunflowers","Cauliflower","Companions" +"Beans (all)","Cauliflower","Companions" +"Broccoli","Cauliflower","Companions" +"Cabbage","Cauliflower","Companions" +"Tomatoes","Cauliflower","Companions" +"Brussels Sprouts","Cauliflower","Companions" +"Rue","Cauliflower","Antagonists" +"Broccoli","Celery","Companions" +"Cabbage","Celery","Companions" +"Potatoes","Celery","Antagonists" +"Parsnips","Celery","Antagonists" +"Broccoli","Chervil","Companions" +"Lettuce","Chervil","Companions" +"Carrots","Chives","Companions" +"Tomatoes","Chives","Companions" +"Broccoli","Chives","Companions" +"Cabbage","Chives","Companions" +"Mustard","Chives","Companions" +"Cauliflower","Chives","Companions" +"Strawberries","Chives","Companions" +"Beans (all)","Chives","Antagonists" +"Peas","Chives","Antagonists" +"Cabbage","Coriander","Companions" +"Spinach","Coriander","Companions" +"Anise","Coriander","Companions" +"Beans (all)","Coriander","Companions" +"Peas","Coriander","Companions" +"Mustard","Corn","Companions" +"Melons","Corn","Companions" +"Beans (all)","Cucumbers","Companions" +"Nasturtiums","Cucumbers","Companions" +"Beets","Cucumbers","Companions" +"Carrots","Cucumbers","Companions" +"Onions","Cucumbers","Companions" +"Celery","Cucumbers","Companions" +"Spinach","Cucumbers","Companions" +"Cabbage","Cucumbers","Companions" +"Sage","Cucumbers","Antagonists" +"Cabbage","Dill","Companions" +"Beans (all)","Dill","Companions" +"Radishes","Dill","Companions" +"Sunflowers","Dill","Companions" +"Onions","Dill","Companions" +"Eggplant","Dill","Companions" +"Carrots","Dill","Antagonists" +"Eggplant","Fennel","Companions" +"Basil","Fennel","Companions" +"Coriander","Fennel","Antagonists" +"Beans (most)","Fennel","Antagonists" +"Peppers","Marigolds","Companions" +"Beans (all)","Marigolds","Companions" +"Zucchini","Marigolds","Companions" +"Cabbage","Marigolds","Companions" +"Onions","Marigolds","Companions" +"Garlic","Marigolds","Companions" +"Chives","Marigolds","Companions" +"Shallot","Marigolds","Companions" +"Broccoli","Garlic","Companions" +"Cabbage","Garlic","Companions" +"Lettuce","Garlic","Companions" +"Tarragon","Garlic","Companions" +"Celery","Garlic","Companions" +"Peas","Garlic","Antagonists" +"Beans (all)","Garlic","Antagonists" +"Beans (all)","Grape Vine","Companions" +"Peas","Grape Vine","Companions" +"Oregano","Grape Vine","Companions" +"Geraniums","Grape Vine","Companions" +"Cabbage","Grape Vine","Antagonists" +"Beets","Kale","Companions" +"Celery","Kale","Companions" +"Spinach","Kale","Companions" +"Marigolds","Kale","Companions" +"Cabbage","Kale","Companions" +"Cauliflower","Kale","Companions" +"Nasturtiums","Kale","Companions" +"Aromatic Herbs","Kale","Companions" +"Grape Vine","Kale","Antagonists" +"Beans (all)","Kale","Antagonists" +"Strawberries","Kale","Antagonists" +"Thyme","Kohlrabi","Companions" +"Sage","Kohlrabi","Companions" +"Cabbage","Kohlrabi","Companions" +"Cauliflower","Kohlrabi","Companions" +"Onions","Kohlrabi","Companions" +"Aromatic Herbs","Kohlrabi","Companions" +"Climbing Bean","Kohlrabi","Antagonists" +"Peppers","Kohlrabi","Antagonists" +"Fennel","Kohlrabi","Antagonists" +"Beans (Bush & Climbing)","Lettuce","Companions" +"Carrots","Lettuce","Companions" +"Onions","Lettuce","Companions" +"Kohlrabi","Lettuce","Companions" +"Thyme","Lettuce","Companions" +"Nasturtiums","Lettuce","Companions" +"Parsnips","Lettuce","Companions" +"Cabbage","Lettuce","Antagonists" +"Celery","Lettuce","Antagonists" +"Squash","Marjoram","Companions" +"Beans (all)","Marjoram","Companions" +"Eggplant","Marjoram","Companions" +"Beans (all)","Mustard","Companions" +"Cabbage","Mustard","Companions" +"Radishes","Mustard","Companions" +"Cauliflower","Mustard","Companions" +"Brussels Sprouts","Mustard","Companions" +"Turnips","Mustard","Companions" +"Alfalfa","Mustard","Companions" +"Beans (all)","Nasturtiums","Companions" +"Cabbage","Nasturtiums","Companions" +"Tomatoes","Nasturtiums","Companions" +"Broccoli","Nasturtiums","Companions" +"Brussels Sprouts","Nasturtiums","Companions" +"Cucumbers","Nasturtiums","Companions" +"Potatoes","Nasturtiums","Companions" +"Cauliflower","Nasturtiums","Antagonists" +"Carrots","Onions","Companions" +"Strawberries","Onions","Companions" +"Chamomile","Onions","Companions" +"Beets","Onions","Companions" +"Cabbage","Onions","Companions" +"Cauliflower","Onions","Companions" +"Lettuce","Onions","Companions" +"Parsnips","Onions","Companions" +"Peppers","Onions","Companions" +"Cucumbers","Onions","Companions" +"Dill","Onions","Companions" +"Marigolds","Onions","Companions" +"Tomatoes","Onions","Companions" +"Savory","Onions","Companions" +"Broccoli","Onions","Companions" +"Peas","Onions","Antagonists" +"Lentils","Onions","Antagonists" +"Asparagus","Onions","Antagonists" +"Cabbage","Oregano","Companions" +"Cauliflower","Oregano","Companions" +"Cucumbers","Oregano","Companions" +"Asparagus","Parsley","Companions" +"Onions","Parsley","Antagonists" +"Garlic","Parsley","Antagonists" +"Chives","Parsley","Antagonists" +"Shallot","Parsley","Antagonists" +"Mint","Parsley","Antagonists" +"Beans (bush)","Parsnips","Companions" +"Peppers","Parsnips","Companions" +"Potatoes","Parsnips","Companions" +"Radishes","Parsnips","Companions" +"Carrots","Parsnips","Antagonists" +"Celery","Parsnips","Antagonists" +"Carrots","Peas","Companions" +"Eggplant","Peas","Companions" +"Turnips","Peas","Companions" +"Broccoli","Peas","Companions" +"Brussels Sprouts","Peas","Companions" +"Mint","Peas","Companions" +"Beans (all)","Peas","Companions" +"Chives","Peas","Antagonists" +"Potatoes","Peas","Antagonists" +"Onions","Peas","Antagonists" +"Basil","Peppers","Companions" +"Tomatoes","Peppers","Companions" +"Sunflowers","Peppers","Companions" +"Carrots","Peppers","Companions" +"Eggplant","Peppers","Companions" +"Onions","Peppers","Companions" +"Parsley","Peppers","Companions" +"Okra","Peppers","Companions" +"Marjoram","Peppers","Companions" +"Mustard","Peppers","Companions" +"Geraniums","Peppers","Companions" +"Petunias","Peppers","Companions" +"Beans (all)","Peppers","Antagonists" +"Kale","Peppers","Antagonists" +"Fennel","Peppers","Antagonists" +"Kohlrabi","Peppers","Antagonists" +"Brussels Sprouts","Peppers","Antagonists" +"Cabbage","Pennyroyal","Companions" +"Kale","Pennyroyal","Companions" +"Cauliflower","Pennyroyal","Companions" +"Beans (all)","Potatoes","Companions" +"Horseradish","Potatoes","Companions" +"Basil","Potatoes","Companions" +"Cabbage","Potatoes","Companions" +"Eggplant","Potatoes","Companions" +"Peas","Potatoes","Companions" +"Broccoli","Potatoes","Companions" +"Onions","Potatoes","Companions" +"Clover","Potatoes","Companions" +"Carrots","Potatoes","Antagonists" +"Walnut","Potatoes","Antagonists" +"Squash","Pumpkins","Companions" +"Beans (all)","Pumpkins","Companions" +"Oregano","Pumpkins","Companions" +"Radishes","Pumpkins","Companions" +"Eggplant","Radishes","Companions" +"Peas","Radishes","Companions" +"Beans (all)","Radishes","Companions" +"Melons","Radishes","Companions" +"Brussels Sprouts","Radishes","Antagonists" +"Turnips","Radishes","Antagonists" +"Cabbage","Rosemary","Companions" +"Beans (all)","Rosemary","Companions" +"Carrots","Rosemary","Companions" +"Tomatoes","Rosemary","Antagonists" +"Lavender","Rue","Companions" +"Carrots","Rue","Companions" +"Broccoli","Rue","Antagonists" +"Cabbage","Rue","Antagonists" +"Cauliflower","Sage","Companions" +"Carrots","Sage","Companions" +"Cabbage","Sage","Companions" +"Marjoram","Sage","Companions" +"Beans (all)","Sage","Companions" +"Cucumbers","Sage","Antagonists" +"Onions","Sage","Antagonists" +"Rue","Sage","Antagonists" +"Beans (all)","Savory","Companions" +"Onions","Savory","Companions" +"Melons","Savory","Companions" +"Asparagus","Soybeans","Companions" +"Potatoes","Soybeans","Companions" +"Beans (all)","Soybeans","Antagonists" +"Onions","Soybeans","Antagonists" +"Garlic","Soybeans","Antagonists" +"Peas","Spinach","Companions" +"Beans (all)","Spinach","Companions" +"Celery","Spinach","Companions" +"Eggplant","Spinach","Companions" +"Broccoli","Spinach","Companions" +"Beans (all)","Squash","Companions" +"Okra","Squash","Companions" +"Tansy","Squash","Companions" +"Onions","Strawberries","Companions" +"Cabbage","Strawberries","Antagonists" +"Tomatoes","Strawberries","Antagonists" +"Potatoes","Strawberries","Antagonists" +"Eggplant","Strawberries","Antagonists" +"Peppers","Strawberries","Antagonists" +"Melons","Strawberries","Antagonists" +"Okra","Strawberries","Antagonists" +"Mint","Strawberries","Antagonists" +"Chamomile","Stinging Nettle","Companions" +"Marjoram","Stinging Nettle","Companions" +"Mint","Stinging Nettle","Companions" +"Broccoli","Stinging Nettle","Companions" +"Sage","Stinging Nettle","Companions" +"Peppers","Sunflowers","Companions" +"Tomatoes","Sunflowers","Companions" +"Swan Plant","Sunflowers","Companions" +"Garlic","Sunflowers","Antagonists" +"Beans (bush)","Swiss Chard","Companions" +"Kohlrabi","Swiss Chard","Companions" +"Onions","Swiss Chard","Companions" +"Broccoli","Swiss Chard","Companions" +"Brussels Sprouts","Swiss Chard","Companions" +"Cabbage","Swiss Chard","Companions" +"Radishes","Swiss Chard","Companions" +"Turnips","Swiss Chard","Companions" +"Beans (climbing)","Swiss Chard","Antagonists" +"Eggplant","Tarragon","Companions" +"Tomatoes","Tarragon","Companions" +"Peppers","Tarragon","Companions" +"Cabbage","Thyme","Companions" +"Brussels Sprouts","Thyme","Companions" +"Eggplant","Thyme","Companions" +"Beans (all)","Tomatoes","Companions" +"Oregano","Tomatoes","Companions" +"Broccoli","Tomatoes","Companions" +"Cabbage","Tomatoes","Companions" +"Peppers","Tomatoes","Companions" +"Chives","Tomatoes","Companions" +"Carrots","Tomatoes","Companions" +"Eggplant","Tomatoes","Companions" +"Mint","Tomatoes","Companions" +"Mustard","Tomatoes","Companions" +"Rosemary","Tomatoes","Companions" +"Walnut","Tomatoes","Antagonists" +"Broccoli","Turnips","Companions" +"Peas","Turnips","Companions" +"Cabbage","Turnips","Companions" +"Potatoes","Turnips","Antagonists" +"Radishes","Turnips","Antagonists" +"Carrots","Turnips","Antagonists" +"Mustard","Turnips","Antagonists" +"Most Plants (especially aromatic)","Yarrow","Companions" +"Chervil","Yarrow","Companions" +"Grape Vine","Yarrow","Companions" +"Corn","Zucchini","Companions" +"Marjoram","Zucchini","Companions" +"Parsnips","Zucchini","Companions" +"Potatoes","Zucchini","Antagonists" diff --git a/images/gh_app.png b/images/gh_app.png index a1316aa..be7c6a1 100644 Binary files a/images/gh_app.png and b/images/gh_app.png differ diff --git a/images/gh_app_m.png b/images/gh_app_m.png index 264f4ea..37c8014 100644 Binary files a/images/gh_app_m.png and b/images/gh_app_m.png differ diff --git a/images/gh_app_old.png b/images/gh_app_old.png new file mode 100644 index 0000000..a1316aa Binary files /dev/null and b/images/gh_app_old.png differ diff --git a/script/relationship_data_cleaning.R b/script/relationship_data_cleaning.R index 15cce39..9afe268 100644 --- a/script/relationship_data_cleaning.R +++ b/script/relationship_data_cleaning.R @@ -25,6 +25,20 @@ raw_wldata <- dplyr::rename(second_plant = X1) |> dplyr::relocate(plant, .before = "second_plant") +# Reflexive completion +# Not all relationships are included; for example, Basil has Chamomile listed as +# a companion, but Chamomile does not have Basil listed as a companion +completed_raw_data <- + raw_wldata |> + rbind( + raw_wldata |> + dplyr::rename( + second_plant = plant, + plant = second_plant) |> + dplyr::relocate(plant, .before = "second_plant") + ) |> + dplyr::distinct() + # Define plants unwanted in final output excluded <- c("Fruit Trees", "Apple", "Apricot", "Cherry", "Grape", "Blackberries", @@ -33,7 +47,7 @@ excluded <- # Clean up raw data clean_data <- - raw_wldata |> + completed_raw_data |> dplyr::filter(is.na(comment)) |> dplyr::select(-comment) |> # Filter out excluded plants @@ -159,4 +173,4 @@ clean_data <- !(plant == "Garlic" & second_plant == "Peas" & relationship == "Companions")) # Write out csv for shiny app -write.csv(clean_data, "clean_data/plant_relationships.csv", row.names = F) \ No newline at end of file +write.csv(clean_data, "clean_data/plant_relationships.csv", row.names = F) diff --git a/ui.R b/ui.R index f58cf87..9257587 100644 --- a/ui.R +++ b/ui.R @@ -25,7 +25,6 @@ ui <- # Sidebar with input options: sidebarLayout( sidebarPanel( - # Initialize shinyStore: initStore("store", "shinyStore-mac-app"), @@ -47,8 +46,8 @@ ui <- # Main panel: mainPanel( + br(), h3("Friends & Foes"), - br(), fluidRow(plotOutput("ffPlot")), h4("Friends (comprehensive list):"), fluidRow(column(width = 10, tableOutput("friend_list"))), @@ -140,11 +139,11 @@ server <- function(input, output, session) { legend.text = ggplot2::element_text(size = 15), legend.direction = "vertical", - plot.margin = + plot.margin = ggplot2::unit(c(0, 0, 0, 0), "cm")) + ggplot2::scale_fill_manual( - values = c("Antagonists" = "#FDE725", "Companions" = "#7AD151")) - }) + values = c("Antagonists" = "#3a1e04", "Companions" = "#7AD151")) + }, bg = "transparent") # Friend list: output$friend_list <-