Skip to content

plot_recruitment does not group lists #211

@kellijohnson-NOAA

Description

@kellijohnson-NOAA

I am running

stockplotr::plot_recruitment(
  list(
    "asap" = output_asap,
    "fims" = output_fims
  )
)

and I figured that I would get two lines, one for each element of the list. Instead, I am just getting one line. The problem, I think, is in this section of process_data()

  if (is.null(group)) {
    data <- dplyr::mutate(data, group_var = "1")
  } else if (length(unique(data[[group]])) == 1) {
    data <- dplyr::mutate(data, group_var = "1")
    group <- NULL
  } else {
    if (group != "none") {
      data <- dplyr::mutate(data, group_var = .data[[group]]) |>
        dplyr::filter(!is.na(group_var))
    } else {
      # change group back to NULL bc no longer needs data processing
      group <- NULL
    }
  }

where group is NULL so it assigns group_var to 1 and plots everything as one group. But, I was assuming that because I put my data in as a list that I would get two lines and that I did not have to do anything additional such as assign some faceting or grouping.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions