Skip to content

refactor(split_functional_groups)#20

Open
kellijohnson-NOAA wants to merge 1 commit into
mainfrom
group-fxn
Open

refactor(split_functional_groups)#20
kellijohnson-NOAA wants to merge 1 commit into
mainfrom
group-fxn

Conversation

@kellijohnson-NOAA
Copy link
Copy Markdown
Contributor

What is the feature?

  • 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.

How have you implemented the solution?

  • PascalCase and camelCase words are first transformed to sentence case and leading brackets are transformed to a space and trailing brackets are removed.
  • split_functional_groups() looks for common groups by searching character by character through all combinations of x.
  • Words are then split between common groups and trailing information. The trailing information is the grouping and common group is the species.
  • A data frame is returned (same as before).

Does the PR impact any other area of the project, maybe another repo?

  • @Bai-Li-NOAA can you test this on your functional groups for the simulation project to see if I need to do any augmenting.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Bai-Li-NOAA
Copy link
Copy Markdown
Collaborator

@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.

@kellijohnson-NOAA
Copy link
Copy Markdown
Contributor Author

Thanks @Bai-Li-NOAA for the csv file. The function that I wrote completely fails 🤣. I will try again.

@Bai-Li-NOAA
Copy link
Copy Markdown
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants