Skip to content

Commit

Permalink
Four datasets from {babynames} are added
Browse files Browse the repository at this point in the history
  • Loading branch information
phgrosjean committed Sep 10, 2023
1 parent c360733 commit cff7367
Show file tree
Hide file tree
Showing 12 changed files with 214 additions and 1 deletion.
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Suggests:
writexl,
datasets,
ggplot2,
lme4,
babynames,
nycflights13,
palmerpenguins,
covr,
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

- The data sets `Penicillin` and `sleepstudy` from {lme4} are now translated (en and fr versions).

- The data sets `babynames`, `applicants`, `births`, and `lifetables` from {babynames} are now translated (en and fr versions).

# data.io 1.4.1

- There was a conflict in attributing units with the {units} package. So, when this package was loaded, `units(x) <- value` when `x` is numeric became a `units`object treated by {units}. We don't want this, so, the previous code is replaced by `attr(x, "units") <- value` to avoid this clash.
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

- Should we always convert ts and mts objects into data frames? + see `co2`, `nottem`, `pastecs::marbio`, `pastecs::marphy`, `pastecs::releve`.

- Also see `tidyr::who`, `tidyr::population`, `UsingR::babies`, `ca::wg93`, `faraway::eggs`, `mlbench::PimaIndianDiabetes2`
- Also see `tidyr::who`, `tidyr::population`, `vegan::BCI`, `vegan::mite`, `vegan::varespec`, `UsingR::babies`, `ca::wg93`, `faraway::eggs`, `mlbench::PimaIndianDiabetes2`

- Reimplement `options(data.io.lang = "xx")` as `options(SciViews.lang = "xx")`, and make changes in all SciViews packages (this option is not solely for {data.io} indeed).

Expand Down
3 changes: 3 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ allometric
ambitus
Anscombe's
appveyor
babynames
biometry
Cen
cmd
Expand All @@ -25,6 +26,7 @@ labelled
Leptograpsus
LGA
lividus
lme
Loa
Mauna
micromol
Expand All @@ -33,6 +35,7 @@ Morphometric
Morphometry
ORCID
orthogonally
palmerpenguins
Paracentrotus
Ph
phgrosjean
Expand Down
22 changes: 22 additions & 0 deletions inst/translation/applicants_en.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.applicants_en <- function(applicants, labels_only = FALSE, as_labelled = FALSE) {

comment(applicants) <- c(
"Dataset 'applicants' from package 'babynames'")

applicants <- labelise(applicants, self = FALSE,
label = list(
year = "Year",
sex = "Sex",
n_all = "Number"),
units = list(
year = NA,
sex = NA,
n_all = NA),
as_labelled = as_labelled)

#if (!isTRUE(labels_only)) {
# # Nothing to do
#}

applicants
}
22 changes: 22 additions & 0 deletions inst/translation/applicants_fr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.applicants_fr <- function(applicants, labels_only = FALSE, as_labelled = FALSE) {

comment(applicants) <- c(
"Jeu de données 'applicants' du package 'babynames'")

applicants <- labelise(applicants, self = FALSE,
label = list(
year = "Année",
sex = "Genre",
n_all = "Nombre"),
units = list(
year = NA,
sex = NA,
n_all = NA),
as_labelled = as_labelled)

if (!isTRUE(labels_only)) {
applicants$sex[applicants$sex == "M"] <- "H" # Or "F"
}

applicants
}
26 changes: 26 additions & 0 deletions inst/translation/babynames_en.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.babynames_en <- function(babynames, labels_only = FALSE, as_labelled = FALSE) {

comment(babynames) <- c(
"Data set 'babynames' from package 'babynames'")

babynames <- labelise(babynames, self = FALSE,
label = list(
year = "Year",
sex = "Sex",
name = "Name",
n = "Number",
prop = "Proportion"),
units = list(
year = NA,
sex = NA,
name = NA,
n = NA,
prop = NA),
as_labelled = as_labelled)

#if (!isTRUE(labels_only)) {
# Nothing to do!
#}

babynames
}
26 changes: 26 additions & 0 deletions inst/translation/babynames_fr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.babynames_fr <- function(babynames, labels_only = FALSE, as_labelled = FALSE) {

comment(babynames) <- c(
"Jeu de données 'babynames' du package 'babynames'")

babynames <- labelise(babynames, self = FALSE,
label = list(
year = "Année",
sex = "Genre",
name = "Nom",
n = "Nombre",
prop = "Proportion"),
units = list(
year = NA,
sex = NA,
name = NA,
n = NA,
prop = NA),
as_labelled = as_labelled)

if (!isTRUE(labels_only)) {
babynames$sex[babynames$sex == "M"] <- "H" # Or "F"
}

babynames
}
20 changes: 20 additions & 0 deletions inst/translation/births_en.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.births_en <- function(births, labels_only = FALSE, as_labelled = FALSE) {

comment(births) <- c(
"Dataset 'births' from package 'babynames'")

births <- labelise(births, self = FALSE,
label = list(
year = "Year",
births = "Births"),
units = list(
year = NA,
births = NA),
as_labelled = as_labelled)

#if (!isTRUE(labels_only)) {
# # Nothing to do
#}

births
}
20 changes: 20 additions & 0 deletions inst/translation/births_fr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.births_fr <- function(births, labels_only = FALSE, as_labelled = FALSE) {

comment(births) <- c(
"Jeu de données 'births' du package 'babynames'")

births <- labelise(births, self = FALSE,
label = list(
year = "Année",
births = "Naissances"),
units = list(
year = NA,
births = NA),
as_labelled = as_labelled)

#if (!isTRUE(labels_only)) {
# # Nothing to do
#}

births
}
34 changes: 34 additions & 0 deletions inst/translation/lifetables_en.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.lifetables_en <- function(lifetables, labels_only = FALSE, as_labelled = FALSE) {

comment(lifetables) <- c(
"Data set 'lifetables' from package 'babynames'")

lifetables <- labelise(lifetables, self = FALSE,
label = list(
x = "Age",
qx = "Mortality probability at x",
lx = "Survivors/100000 at x+1",
dx = "Mortality at x+1",
Lx = "Person-years (x - x+1)",
Tx = "Total person-years (>x)",
ex = "Life expectancy at x",
sex = "Sex",
year = "Year"),
units = list(
x = "years",
qx = NA,
lx = NA,
dx = NA,
Lx = NA,
Tx = NA,
ex = "years",
sex = NA,
year = NA),
as_labelled = as_labelled)

#if (!isTRUE(labels_only)) {
# # Nothing to do
#}

lifetables
}
36 changes: 36 additions & 0 deletions inst/translation/lifetables_fr.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.lifetables_fr <- function(lifetables, labels_only = FALSE, as_labelled = FALSE) {

comment(lifetables) <- c(
"Jeu de données 'lifetables' du package 'babynames'")

lifetables <- labelise(lifetables, self = FALSE,
label = list(
x = "Âge",
qx = "Probabilité de mortalité à x",
lx = "Survivants/100000 à x+1",
dx = "Mortalité à x+1",
Lx = "Personne-années (x - x+1)",
Tx = "Total personne-années (>x)",
ex = "Espérance de vie à x",
sex = "Genre",
year = "Année"),
units = list(
x = "années",
qx = NA,
lx = NA,
dx = NA,
Lx = NA,
Tx = NA,
ex = "années",
sex = NA,
year = NA),
as_labelled = as_labelled)

if (!isTRUE(labels_only)) {
sex_levels <- levels(lifetables$sex)
sex_levels[sex_levels == "M"] <- "H"
levels(lifetables$sex) <- sex_levels
}

lifetables
}

0 comments on commit cff7367

Please sign in to comment.