Which plants are better for bees: native or non-native?
📖 Background
You work for the local government environment agency and have taken on a project about creating pollinator bee-friendly spaces. You can use both native and non-native plants to create these spaces and therefore need to ensure that you use the correct plants to optimize the environment for these bees.
The team has collected data on native and non-native plants and their effects on pollinator bees. Your task will be to analyze this data and provide recommendations on which plants create an optimized environment for pollinator bees.
💾 The Data
You have assembled information on the plants and bees research in a file called plants_and_bees.csv. Each row represents a sample that was taken from a patch of land where the plant species were being studied.
| Column | Description |
|---|---|
sample_id | The ID number of the sample taken. |
bees_num | The total number of bee individuals in the sample. |
date | Date the sample was taken. |
season | Season during sample collection ("early.season" or "late.season"). |
site | Name of collection site. |
native_or_non | Whether the sample was from a native or non-native plot. |
sampling | The sampling method. |
plant_species | The name of the plant species the sample was taken from. None indicates the sample was taken from the air. |
time | The time the sample was taken. |
bee_species | The bee species in the sample. |
sex | The gender of the bee species. |
specialized_on | The plant genus the bee species preferred. |
parasitic | Whether or not the bee is parasitic (0:no, 1:yes). |
nesting | The bees nesting method. |
status | The status of the bee species. |
nonnative_bee | Whether the bee species is native or not (0:no, 1:yes). |
Source (data has been modified)
💪 Challenge
Provide your agency with a report that covers the following:
- Which plants are preferred by native vs non-native bee species?
- A visualization of the distribution of bee and plant species across one of the samples.
- Select the top three plant species you would recommend to the agency to support native bees.
✅ Checklist before publishing
- Rename your workspace to make it descriptive of your work. N.B. you should leave the notebook name as notebook.ipynb.
- Remove redundant cells like the judging criteria, so the workbook is focused on your work.
- Check that all the cells run without error.
⌛️ Time is ticking. Good luck!
suppressPackageStartupMessages(library(tidyverse))
data <- readr::read_csv("data/plants_and_bees.csv", show_col_types = FALSE)
dataquestions?
- Unsure of difference between nonnative_bee and native_or_non
- --Non native bees - 0 for not native and 1 for native
- --Mative or non plot- seems like secondary information to plant species.
To do:
- Make seondary table of just plant species info-
- ---plant species, native or non, specialized_on (genus info)
- Make secondary table of bee species info-
- --bee_species, nonnative_bee, parasititc, nesting, status
Alternate:
- plant_species == None -> sampled from air
- can see which plot does this come from
- can see which plot has what proportion of native or native plants
Making a primary table
Firstly, I wil remove columns I do not think are required or are redundant.
- Removing date- this info is much better captured in season
- Removing Native_or_non - secondary plant info
- Removing sampling method - not sure how relevant
- Removing time - not sure how relevant
- Removing specialised_on - Higher resolution info given under plant species
- Removing parasitic and nesting method - not relevant to plant
- Remove status- redundant
- Remove rows with 0 value in plant_species
- Remove rows with male bees- female bees as main pollinators
- Remove rows with no native/ non-native bee information
Explain why I have retained these columns
- Leaving in site- maybe different will need different plants planted
- Leaving in plant_species
- Leaving in bee_species
# Make a primary table
# Remove male bees
pmd <- data[-which(data$sex == "m"), ]
# Remove samples collected from air
pmd <- pmd[-which(pmd$plant_species == "None"), ]
# Remove none values from native/non-native bee status
pmd <- pmd[-which(pmd$nonnative_bee == "null"), ]
# Remove unwanted columns
pmd <- subset(pmd, select = -c(date, native_or_non, sampling, time, specialized_on, parasitic, nesting, sex, status))
str(pmd)unique(pmd$site)
unique(pmd$plant_species)
unique(pmd$bee_species)
unique(pmd$nonnative_bee)