-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Four datasets from {babynames} are added
- Loading branch information
1 parent
c360733
commit cff7367
Showing
12 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ Suggests: | |
writexl, | ||
datasets, | ||
ggplot2, | ||
lme4, | ||
babynames, | ||
nycflights13, | ||
palmerpenguins, | ||
covr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |