Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • airGR airGR
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 64
    • Issues 64
    • List
    • Boards
    • Service Desk
    • Milestones
  • Redmine
    • Redmine
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

La forge institutionnelle d'INRAE étant en production depuis le 10 juin 2025, nous vous recommandons d'y créer tous vos nouveaux projets.

  • HYCAR-HydroHYCAR-Hydro
  • airGRairGR
  • Issues
  • #187
Closed
Open
Issue created Apr 11, 2024 by Dorchies David@david.dorchiesDeveloper

SeriesAggreg fails on `tibble` format

> library(airGR)
> data(L0123001)
> str(SeriesAggreg(BasinObs[, 1:2], "%Y%m", ConvertFun = "sum"))
'data.frame':	348 obs. of  2 variables:
 $ DatesR: POSIXct, format: "1984-01-01" "1984-02-01" "1984-03-01" "1984-04-01" ...
 $ P     : num  78.8 85.6 47.4 71.7 77.4 ...
> tibP <- tibble::as_tibble(BasinObs[, 1:2])
> str(SeriesAggreg(tibP, "%Y%m", ConvertFun = "sum"))
tibble [10,593 × 2] (S3: tbl_df/tbl/data.frame)
 $ DatesR: POSIXct[1:10593], format: "1984-01-01" "1984-01-02" "1984-01-03" "1984-01-04" ...
 $ P     : num [1:10593] 4.1 15.9 0.8 0 0 0 0 0 2.9 0 ...
Message d'avis :
Dans SeriesAggreg.data.frame(tibP, "%Y%m", ConvertFun = "sum") :
  the requested time 'Format' is the same as the one in 'x'. No time-step conversion was performed

SeriesAggreg doesn't stop with error but only warns and return a wrong output which is a bit more difficult to take care of...

tibble is a format which inherits from data.frame with more restriction. One of these restriction is that a selection on a tibble returns a tibble by default whereas a data.frame selection returns a vector if you select a single column. This behavior is handled by the parameter drop:

> str(cars[1:5,1])
 num [1:5] 4 4 7 7 8
> str(tibble::as_tibble(cars)[1:5,1])
tibble [5 × 1] (S3: tbl_df/tbl/data.frame)
 $ speed: num [1:5] 4 4 7 7 8
> str(tibble::as_tibble(cars)[1:5, 1, drop = TRUE])
 num [1:5] 4 4 7 7 8

Line 107 of R\SeriesAggreg.data.frame.R: a drop = TRUE is missing in unitTs <- format(diff(x[1:2, 1]))

Moreover, it is not robust to trust the else operator in line 113, we should check everytime the pattern returned by unitTs.

Edited Apr 11, 2024 by Dorchies David
Assignee
Assign to
Time tracking