globalgov / manydata

The portal for global governance data
https://manydata.ch
GNU Affero General Public License v3.0
9 stars 0 forks source link

Bug with `consolidate()` function when resolving multiple 'mdate' variables differently #293

Closed henriquesposito closed 7 months ago

henriquesposito commented 1 year ago
dat1 <- dplyr::tibble(manyID = c("NZL", "BRA", "CHF"),
                      date = messydates::as_messydate(c("1990-01-01",
                                                        "1990-01-02",
                                                        "1990-01-01:1990-01-31")),
                      number = c(100, 1000, 10000))
dat2 <- dplyr::tibble(manyID = c("NZL", "BRA"),
                      date = messydates::as_messydate(c("1990-01-01",
                                                        "1990-01-03")))
dat3 <- dplyr::tibble(manyID = c("NZL", "BRA", "CHF", "OTH"),
                      date = messydates::as_messydate(c("1990-01-01",
                                                        "1990-01-02",
                                                        "1990-01-01:1990-01-31",
                                                        NA)),
                      number = c(100, 1200, 12222, 21))
test2 <- list(a = dat1, b = dat2, c = dat3)
consolidate(test2, "any", "any", resolve = c(date = "min", number = "max"))
consolidate(test2, "every", "any", resolve = c(date = "mean", number = "median"))

These issues appear to have appeared since the latest changes we made to {messydates}, but they appear here.

henriquesposito commented 11 months ago

Just as a note, this bug was related to new changes with how {messydates} understand NAs for logical functions. However, since this is an issue that can happen with other types of variable classes when using consolidate() it was addressed here. This also is an attempt to avoid that expanding {messydates} cause issues with {manydata}.