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

Ajout d'une nouvelle fiche sur les données temporelles (issue #491) #497

Merged
merged 9 commits into from
Dec 4, 2023
Merged

Ajout d'une nouvelle fiche sur les données temporelles (issue #491) #497

merged 9 commits into from
Dec 4, 2023

Conversation

TanguyBarthelemy
Copy link
Contributor

Proposition d'une nouvelle fiche sur les séries temporelles en R.

Copy link
Member

@RLesur RLesur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Génial ! Superbe fiche, ça manquait, merci beaucoup !
Quelques micro suggestions de ma part

03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
| Format américain | AAAA-MM-JJ | 2023-12-25 |

Une date peut aussi désigner un horaire ou un moment précis. On peut
alors spécifier les heures, les minutes, les secondes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Et les fuseaux horaires ? Pour mémoire, la France est le pays qui a le plus grand nombre de fuseaux horaires au monde (13 en tout)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, je propose de modifier la remarque en précisant :

Une date peut aussi désigner un horaire ou un moment précis à un fuseau horaire. On peut alors spécifier les heures, les minutes, les secondes et le fuseau de l'évènement.
Par exemple :

  • la date 2023-05-24T04:03:00Z désigne le 24 mai 2023 à 4h03 au fuseau UTC.
  • la date 2023-02-11T12:37:00-04:00 désigne le 11 février 2023 à 12h37 dans une zone de fuseau horaire -4h (par exemple les antilles ou la bolivie).

Aussi j'en parle dans cette partie :

### Les différents fuseaux horaires

Je ne sais pas si il y a besoin de préciser plus.

Copy link
Contributor

@linogaliana linogaliana Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ça me semble très bien comme proposition

03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved

Pour créer une date en R, il suffit de faire appel à la fonction
`as.Date()`{.r} du package `base`. Par défaut, l'argument format
correspond au format américain :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non, ce n'est pas le format américain, c'est la norme ISO 8601, celle que nous devrions tous utiliser, même en France. Le problème ici est nos usages en France, pas les USA

Copy link
Contributor Author

@TanguyBarthelemy TanguyBarthelemy Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok ! Je n'avais pas très bien compris cette remarque d'ISO et de format de date.

Je propose de changer le tableau en :

Type Exemple (Noël 2023)
JJ/MM/AAAA 25/12/2023
AAAA-MM-JJ 2023-12-25

et simplement de renvoyer à l'encadré sur les normes :

### Les normes ISO8601 et RFC3339
Les normes ISO8601 et RFC3339 sont des conventions de représentation des
dates. Selon ces 2 normes, certains formats de dates sont acceptés ou
non.
Par exemple, voici quelques format représentant la date du 24 mai 2023 à
8h43 (UTC) :
- `"2023-05-24T08:43:00Z"`{.r} est un format accepté par ces 2 normes.
- `"2023-05-24t08:43:00z"`{.r} est un format accepté uniquement par la
norme RFC3339.
- `"2023-05-24T08:43Z"`{.r} est un format accepté uniquement par la
norme ISO8601.
Pour savoir quels formats sont acceptés par ces normes, une infographie
est disponible [ici](https://ijmacd.github.io/rfc3339-iso8601/) :
https://ijmacd.github.io/rfc3339-iso8601/.
On peut aussi utiliser le package `parsedate` qui permet de lire une
date au format ISO8601
```{r, warning = FALSE}
library("parsedate")
parse_iso_8601("2023-05-24T08:43:00Z") # Accepté par ISO8601
parse_iso_8601("2023-05-24t08:43:00z") # Refusé par ISO8601
parse_iso_8601("2023-05-24T08:43Z") # Accepté par ISO8601
```

?

03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
Comment on lines +457 to +459
library("zoo")

zoo::as.Date(time(serie_mensuelle))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est bizarre de faire un appel à library() suivi de zoo::, non ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui...

  • library() c'est pour montrer qu'on appelle bien ce package
  • et zoo::as.Date() pour expliquer que lorsqu'on utilise cette fonction il faut bien spécifier le package d'origine pour pas se mélanger avec la fonction base::as.Date() (qui a un comportement différent)

J'explique un peu ici :

- La fonction `as.Date()`{.r} existe dans les packages `base` et
`zoo`, mais n'a pas la même fonctionnalité. A chaque fois qu'elle
sera utilisée, on précisera son package d'origine au moyen de `::`
(`base::as.Date()`{.r} ou `zoo::as.Date()`{.r}).

Copy link

@julienjamme julienjamme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La fiche est très claire et j'ai appris des trucs !
Seulement quelques coquilles à corriger.

03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
03_Fiches_thematiques/Fiche_donnees_temporelles.qmd Outdated Show resolved Hide resolved
Co-authored-by: Romain Lesur <RLesur@users.noreply.github.com>
```{r}
# En minutes
units(age) <- "mins"
print(age)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Il me semble qu'on peut faire aussi en une ligne :

print(age, units = "mins")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chez moi cela ne marche pas...

print(age, units = "mins")
Time difference of 29599 days

Selon la version de R (je suis en version 4.3.0) ?

TanguyBarthelemy and others added 7 commits September 26, 2023 10:25
Co-authored-by: Romain Lesur <RLesur@users.noreply.github.com>
Co-authored-by: Romain Lesur <RLesur@users.noreply.github.com>
Co-authored-by: Romain Lesur <RLesur@users.noreply.github.com>
Co-authored-by: Romain Lesur <RLesur@users.noreply.github.com>
@linogaliana linogaliana merged commit 3ab85d5 into InseeFrLab:master Dec 4, 2023
1 check failed
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

Successfully merging this pull request may close these issues.

6 participants