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

Données perdues avec changement_COG_varNum #22

Open
sambafall opened this issue Oct 4, 2024 · 1 comment
Open

Données perdues avec changement_COG_varNum #22

sambafall opened this issue Oct 4, 2024 · 1 comment

Comments

@sambafall
Copy link

sambafall commented Oct 4, 2024

Bonjour,
En utilisant la fonction changement_COG_varNum on perd des données lorsqu'elles contiennent des NA.
Voici un exemple:
`library(COGugaison)

df = data.frame(code=c("01138", "01138", "01006"), valeur=c(NA, 3, 4))

changement_COG_varNum(table_entree = df, codgeo_entree = "code",
annees = c(2011:2023), donnees_insee = FALSE, agregation = TRUE)`
qui donne :

   code valeur
1 01006      4
2 01138     NA

Cela viendrait de cette ligne:
aggregate(table_finale[,c(var_num)],by =list(with(table_finale,get(codgeo_entree))),FUN=sum)

Je n'ai pas testé mais il semblerait qu'en ajoutant na.rm = TRUE qu'on ait le resultat désiré ici càd:

   code valeur
1 01006      4
2 01138     3

Est-il possible d'ajouter cette option à la fonction du genre:
changement_COG_varNum(enlever_na=TRUE|FALSE)
?

@sambafall
Copy link
Author

Testé localement ça fonctionne bien

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

1 participant