refactor(split_functional_groups)#20
Conversation
Split functional groups from left to right rather than right to left. This allows for all types of patterns to be matched rather than relying on a certain formatting for the grouping structure within a species.
| #' | ||
| #' @param x A character vector of functional group names. This is most often | ||
| #' created by running [unique()] on the functional group column of the data. | ||
| #' @param species_group_pattern A vector of two character strings that will be |
There was a problem hiding this comment.
I don’t see species_group_pattern being used in the function. It’s possible that there are some changes on your local machine that haven’t been pushed to the repository yet.
| @@ -22,89 +41,133 @@ utils::globalVariables(c("functional_group", "species", "group")) | |||
| #' data("ewe_nwatlantic_base", package = "ecosystemdata") | |||
| #' split_functional_groups(unique(ewe_nwatlantic_base[["functional_group"]])) | |||
| split_functional_groups <- function(x) { | |||
There was a problem hiding this comment.
find_common_groups() may identify any shared prefix between two names. For example:
split_functional_groups(c("Atlantic cod", "Atlantic herring"))
# A tibble: 2 × 3
functional_group species group
<chr> <chr> <chr>
1 Atlantic cod Atlantic cod
2 Atlantic herring Atlantic herring|
@kellijohnson-NOAA thank you for working on this! It’s quite complex, and I’m not sure where I would even begin if I were tackling this issue. Here is the 1-Basic estimates_two_columns.csv I used for testing. I removed the actual EwE model settings and kept only the functional names for simplicity. |
|
Thanks @Bai-Li-NOAA for the csv file. The function that I wrote completely fails 🤣. I will try again. |
|
@kellijohnson-NOAA Could you wait to address the issue until after I bring the code into {ecosystemom}? I’ll create a new issue there with more instructions. |
What is the feature?
How have you implemented the solution?
split_functional_groups()looks for common groups by searching character by character through all combinations ofx.Does the PR impact any other area of the project, maybe another repo?