Skip to content

process.data() does not process groups correctly with tibble inputs #16

@vgherard

Description

@vgherard

Dear Jeff, I just stumbled into this:

tbl <- tibble::tibble(ch = c("1001", "1010", "0110"), 
                     sex = factor(c("M", "M", "F"))
                     )

attempt1 <- tbl |>
  marked::process.data(groups = "sex")
#> Warning: Unknown or uninitialised column: `Freq`.
#> Warning: Unknown or uninitialised column: `freq`.
#> 3 capture histories collapsed into 3
#> Warning: Unknown or uninitialised column: `id`.
#> Error in marked::process.data(tbl, groups = "sex"): 
#>   sex  is not a factor variable

attempt2 <- tbl |>
  as.data.frame() |>
  marked::process.data(groups = "sex")
#> 3 capture histories collapsed into 3

Created on 2024-04-06 with reprex v2.1.0

I traced the error back to process.data.R#L413, that is:

vari = data[, groups[i]]

This kind of subsetting does not produce a factor with tidyverse tibbles.

Thought you may want to know. Thanks for this nice library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions