Skip to content

Commit

Permalink
The data sets Penicillin and sleepstudy from {lme4} are now trans…
Browse files Browse the repository at this point in the history
…lated (en and fr versions).
  • Loading branch information
phgrosjean committed Sep 10, 2023
1 parent e3ed083 commit c360733
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- The {datasets} `ChickWeight`, `failthful`, `ToothGrowth` are now translated (en and fr versions).

- The data sets `Penicillin` and `sleepstudy` from {lme4} 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
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# data.io To Do list

- 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`

- 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).

- Check the {units} package and verify there is no conflicts any more, or better, use it. Make sure one could use `units(x)` ans `units(x) <- value` or another form on all vectors.
Expand Down
22 changes: 22 additions & 0 deletions inst/translation/Penicillin_en.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.Penicillin_en <- function(Penicillin, labels_only = FALSE, as_labelled = FALSE) {

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

Penicillin <- labelise(Penicillin, self = FALSE,
label = list(
diameter = "Inhibition zone diameter",
plate = "Assay plate",
sample = "Penicillin sample"),
units = list(
diameter = "mm",
plate = NA,
sample = NA),
as_labelled = as_labelled)

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

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

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

Penicillin <- labelise(Penicillin, self = FALSE,
label = list(
diameter = "Diamètre de la zone d'inhibition",
plate = "Boîte de Petri",
sample = "Échantillon de pénicilline"),
units = list(
diameter = "mm",
plate = NA,
sample = NA),
as_labelled = as_labelled)

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

Penicillin
}
2 changes: 1 addition & 1 deletion inst/translation/lynx_en.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
time = "Time",
trapping = "Lynx trapped"),
units = list(
time = NA,
time = "years",
trapping = NA),
as_labelled = as_labelled)

Expand Down
4 changes: 2 additions & 2 deletions inst/translation/lynx_fr.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

lynx <- labelise(lynx, self = FALSE,
label = list(
time = "Time",
time = "Temps",
trapping = "Lynx capturés"),
units = list(
time = NA,
time = "années",
trapping = NA),
as_labelled = as_labelled)

Expand Down
23 changes: 23 additions & 0 deletions inst/translation/sleepstudy_en.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.sleepstudy_en <- function(sleepstudy, labels_only = FALSE, as_labelled = FALSE) {

names(sleepstudy) <- c("reaction", "days", "subject")
comment(sleepstudy) <- c(
"Dataset 'sleepstudy' from the package 'lme4' (column names in lowercase)")

sleepstudy <- labelise(sleepstudy, self = FALSE,
label = list(
reaction = "Reaction time",
days = "Sleep deprivation",
subject = "Subject id"),
units = list(
reaction = "ms",
days = "days",
subject = NA),
as_labelled = as_labelled)

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

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

names(sleepstudy) <- c("reaction", "days", "subject")
comment(sleepstudy) <- c(
"Jeu de données 'sleepstudy' du package 'lme4' (noms de colonnes en minuscules)")

sleepstudy <- labelise(sleepstudy, self = FALSE,
label = list(
reaction = "Temps de réaction",
days = "Privation de sommeil",
subject = "Id sujet"),
units = list(
reaction = "ms",
days = "jours",
subject = NA),
as_labelled = as_labelled)

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

sleepstudy
}

0 comments on commit c360733

Please # to comment.