# INBO CODING CLUB
24 October, 2019
Welcome!
## Share your code snippet
If you want to share your code snippet, copy paste your snippet within a section of three backticks (```)```:
As an **example**:
```r
library(tidyverse)
...
```
(*you can copy paste this example and add your code further down, but do not fill in your code in this section*)
Your snippets:
### Challenge 1
```
species_df %>%
mutate(species_id = str_to_lower(species_id), taxa = str_to_lower(taxa))
id <- species_df %>%
arrange(species_id) %>% select(species_id)
as.vector(id, mode = "character")
species_df %>% filter(str_length(species_id)>2)
```
```
### Set columns `species_id` and `taxa` lowercase
species_df$species_id <- str_to_lower(species_df$species_id)
species_df <- species_df %>%
mutate(species_id = str_to_lower(species_id),
taxa = str_to_lower(taxa))
### sort vector of species_id label alphabetically
str_sort(species_df$species_id)
### extract species_id labels longer than 2 letters
ind <- which(str_length(species_df$species_id) > 2)
species_df$species_id[ind]
```
### Challenge 2
```
# genus + species in new column called canonicalName
species_df <- species_df %>%
mutate(canonicalName = str_c(genus, species, sep=" ") )
# Remove census related label from taxa column
species_df <- species_df %>%
mutate(taxa = str_replace(taxa, "-not censused", ""))
OR:
species_df_census <- species_df %>%
filter(str_detect(taxa , pattern = 'not censused') == FALSE)
```
```
### genus + species in new column called canonicalName
data <- data %>%
mutate(canonicalName = str_c(genus, species, sep = " "))
# Remove census related label from taxa column
data <- data %>%
mutate(taxa = str_remove(taxa, "-not censused"))
# species_df <- species_df %>%
mutate(taxa = str_replace(taxa, '-not censused', ""))
```
### Challenge 3
```
```
# my code...
```