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

Dealing with the "observationTags" column of observations #120

Open
ddachs opened this issue Sep 18, 2024 · 1 comment
Open

Dealing with the "observationTags" column of observations #120

ddachs opened this issue Sep 18, 2024 · 1 comment

Comments

@ddachs
Copy link

ddachs commented Sep 18, 2024

When dealing with custom attributes one has to extract them from the observationTags column. Otherwise the column is useless.

IMO the ideal behaviour of the observations() function would be to split the observationTags n columns, where n beeing the number of unique tags. At least the option would be nice to have e.g. ( observations(x, splitObservationTags = T)

Something like this:

convert_customTags <- function(x) {

observation_tags <-
  separate_wider_delim (
    x %>% filter(!is.na(observationTags)) %>%
      select(observationID, observationTags),
      observationTags,
      names = LETTERS[1:10],
      too_few = "align_start",
      delim = "|",
      cols_remove = T
                                         ) %>%
  pivot_longer(cols = (A:J),
                        names_to = "letter",
                        values_to = "text") %>%
  filter(!is.na(text)) %>%
  select(-letter) %>%
  separate_wider_delim(cols = "text",
                                     delim = ":",
                                     names = c("tag", "value"),
                                     too_few = "align_start") %>%
  pivot_wider(names_from = tag, values_from = value) %>%
  as.data.table()

y <- merge.data.table(observations, observation_tags, on= "observationID", all.x = T)

return(y)
}

Although this has the flaw, that it only works up to 10 custom attributes. Maybe someone has a better idea?

@peterdesmet
Copy link
Member

That is a good suggestion. The same is true for deploymentTags. Will have to think how to best implement this. Options:

  • Unpack tags with dedicated function
  • Unpack when calling observations(), optionally with a parameter
  • As part of read_camtrapdp() cf. how we assign the taxonomic scope to the observations as separate columns

@sannegovaert @PietrH @damianooldoni thoughts?

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

No branches or pull requests

2 participants