Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampling_effort_new is created during the mapping but unused #80

Open
PietrH opened this issue Sep 26, 2023 · 0 comments
Open

sampling_effort_new is created during the mapping but unused #80

PietrH opened this issue Sep 26, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request invalid This doesn't seem right mapping

Comments

@PietrH
Copy link
Member

PietrH commented Sep 26, 2023

Lien does some cleaning on sampling_effort in a column called sampling_effort_new but I believe it's not actually used in the final output, I believe we still just use the uncleaned sampling_effort from earlier.

Now, the field `sampling_effort` contains some unwanted, repeated hashes. With this code, we remove them:
```{r}
sampling_protocol <-
sampling_protocol %>%
# Split by one or more consecutive vertical pipes, i.e. |, || or |||, and return a list
mutate(sampling_effort_new = str_split(.data$sampling_effort, pattern = "\\|+")) %>%
# remove heading or trailing spaces in each element of each list
mutate(sampling_effort_new = map(.data$sampling_effort_new, ~ str_trim(.))) %>%
# remove empty or NA elements from list and convert to character by using " | " as delimiter
mutate(sampling_effort_new = map_chr(
.data$sampling_effort_new, function(x) paste(x[x != "" & !is.na(x)], collapse = " | ")
)
) %>%
# convert empty strings to NA. empty strings arise in the last step when pasting a character(0) vector, i.e. the input sampling_effort_raw is missing (NA) as in row 6
mutate(sampling_effort_new = ifelse(.data$sampling_effort_new == "",
NA_character_,
.data$sampling_effort_new)
)

@PietrH PietrH added enhancement New feature or request invalid This doesn't seem right mapping labels Sep 26, 2023
@PietrH PietrH self-assigned this Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request invalid This doesn't seem right mapping
Projects
None yet
Development

No branches or pull requests

1 participant