Skip to content

Commit ca6b64c

Browse files
committed
Fix notes, update package to use roxygen and add github actions.
1 parent 2a7ef03 commit ca6b64c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3018
-1247
lines changed

.Rbuildignore

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
genlogo.R
2+
^_pkgdown\.yml$
3+
^figure$
4+
^pkgdown$
5+
^Meta$
6+
^doc$
17
#All packages
28
^.*\.Rproj$
39
^\.Rproj\.user$
@@ -15,3 +21,12 @@
1521
#Specific
1622
^raw-image*$
1723
^articles*$
24+
^\.github$
25+
#Vignette cache
26+
^cran-comments[.].*$
27+
^vignettes/.*[.](pdf|PDF)$
28+
^vignettes/.*[.](r|R)$
29+
^vignettes/[.]install_extras$
30+
^vignettes/.*_cache$
31+
^vignettes/.*_files$
32+
^\.github$

.github/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html

.github/workflows/R-CMD-check.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
2+
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
13+
name: R-CMD-check
14+
15+
jobs:
16+
R-CMD-check:
17+
runs-on: macOS-latest
18+
env:
19+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
20+
steps:
21+
- uses: actions/checkout@v2
22+
- uses: r-lib/actions/setup-r@v1
23+
- name: Install dependencies
24+
run: |
25+
install.packages(c("remotes", "rcmdcheck"))
26+
remotes::install_deps(dependencies = TRUE)
27+
shell: Rscript {0}
28+
- name: Check
29+
run: |
30+
options(crayon.enabled = TRUE)
31+
rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")
32+
shell: Rscript {0}

.gitignore

+16-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
.Rproj.user
1+
# History files
22
.Rhistory
3+
.Rapp.history
4+
5+
# Session Data files
36
.RData
4-
*.pper
5-
*.pper
6-
.DS_Store
7-
.Rproj.user/AF86C25B/pcs/source-pane.pper
8-
.Rproj.user/AF86C25B/pcs/windowlayoutstate.pper
9-
*.pper
7+
8+
# Example code in package build process
9+
*-Ex.R
10+
11+
# Output files from R CMD build
12+
/*.tar.gz
13+
14+
# Output files from R CMD check
15+
/*.Rcheck/
16+
17+
# RStudio files
18+
.Rproj.user/

BioStatR.Rproj

+2
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ LaTeX: pdfLaTeX
1414

1515
BuildType: Package
1616
PackageInstallArgs: --no-multiarch --with-keep.source
17+
PackageBuildArgs: --force
1718
PackageCheckArgs: --as-cran
19+
PackageRoxygenize: rd,collate,namespace,vignette

DESCRIPTION

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: BioStatR
22
Type: Package
33
Title: Initiation à La Statistique Avec R
4-
Version: 3.1.1
5-
Date: 2019-01-26
4+
Version: 3.1.2
5+
Date: 2021-03-13
66
Depends: R (>= 2.10)
77
Imports: ggplot2
88
Authors@R: c(
@@ -16,6 +16,6 @@ LazyData: yes
1616
License: GPL-3
1717
Encoding: UTF-8
1818
Classification/MSC:
19-
URL: http://www-irma.u-strasbg.fr/~fbertran/, https://github.com/fbertran/BioStatR
20-
BugReports: https://github.com/fbertran/BioStatR/issues
21-
RoxygenNote: 6.1.1
19+
URL: http://www-irma.u-strasbg.fr/~fbertran/, https://github.com/fbertran/BioStatR/
20+
BugReports: https://github.com/fbertran/BioStatR/issues/
21+
RoxygenNote: 7.1.1

INDEX

-14
This file was deleted.

NAMESPACE

100755100644
+22-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
import(ggplot2)
2-
importFrom("grDevices", "colorRampPalette", "gray")
3-
importFrom("graphics", "hist", "par", "persp", "rect")
4-
importFrom("stats", "as.formula", "lm", "qchisq", "qf", "qnorm",
5-
"quantile", "sd")
1+
# Generated by roxygen2: do not edit by hand
62

7-
# functions
8-
export(cvar)
9-
export(eta2)
10-
export(panel.hist)
11-
export(poi.ci)
12-
export(binom.ci)
13-
export(plotcdf2)
14-
export(gg_qqplot)
3+
export(binom.ci)
4+
export(cvar)
5+
export(eta2)
6+
export(gg_qqplot)
7+
export(panel.hist)
8+
export(plotcdf2)
9+
export(poi.ci)
10+
import(ggplot2)
11+
importFrom(grDevices,colorRampPalette)
12+
importFrom(grDevices,gray)
13+
importFrom(graphics,hist)
14+
importFrom(graphics,par)
15+
importFrom(graphics,persp)
16+
importFrom(graphics,rect)
17+
importFrom(stats,as.formula)
18+
importFrom(stats,lm)
19+
importFrom(stats,qchisq)
20+
importFrom(stats,qf)
21+
importFrom(stats,qnorm)
22+
importFrom(stats,quantile)
23+
importFrom(stats,sd)

NEWS

-11
This file was deleted.

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# BioStatR 3.1.2
2+
3+
* Update to Roxygen and fix CRAN notes.
4+
15
# BioStatR 3.1.1
26

37
* Update of the reference to the book in the description file.

R/BioStatR-package.R

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#' BioStatR
2+
#'
3+
#' Motivation: Package compagnon du livre Initiation à la statistique avec R.
4+
#' Il contient les codes des chapitres du livre ainsi que les solutions des
5+
#' exercices mais aussi d'autres compléments à découvrir.
6+
#'
7+
#'
8+
#' @name BioStatR
9+
#' @docType package
10+
#' @references F. Bertrand, M. Maumy-Bertrand, Initiation à la Statistique avec
11+
#' R, 3ème edition, ISBN:9782100782826, Dunod, Paris, 2018.
12+
#' @references \emph{Initiation à la Statistique avec R}, Frédéric Bertrand,
13+
#' Myriam Maumy-Bertrand, 2018, ,
14+
#' \url{https://www.dunod.com/sciences-techniques/initiation-statistique-avec-r-cours-exemples-exercices-et-problemes-corriges-0},
15+
#' \url{https://github.com/fbertran/BioStatR/} et
16+
#' \url{https://fbertran.github.io/BioStatR/}
17+
#'
18+
#' @importFrom grDevices colorRampPalette gray
19+
#' @importFrom graphics hist par persp rect
20+
#' @importFrom stats as.formula lm qchisq qf qnorm quantile sd
21+
#' @import ggplot2
22+
#'
23+
#' @examples
24+
#' set.seed(314)
25+
#'
26+
NULL
27+
28+
29+
30+
31+
32+

R/binom.ci.R

+82-55
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,82 @@
1-
binom.ci <- function (x, n, conf.level = 0.95, method = c("Wilson", "exact", "Wald",
2-
"all"))
3-
{
4-
method <- match.arg(method)
5-
bc <- function(x, n, conf.level, method) {
6-
nu1 <- 2 * (n - x + 1)
7-
nu2 <- 2 * x
8-
ll <- if (x > 0)
9-
x/(x + qf(1/2 + conf.level/2, nu1, nu2) * (n - x + 1))
10-
else 0
11-
nu1p <- nu2 + 2
12-
nu2p <- nu1 - 2
13-
pp <- if (x < n)
14-
qf(1/2 + conf.level/2, nu1p, nu2p)
15-
else 1
16-
ul <- ((x + 1) * pp)/(n - x + (x + 1) * pp)
17-
zcrit <- -qnorm((1-conf.level)/2)
18-
z2 <- zcrit * zcrit
19-
p <- x/n
20-
cl <- (p + z2/2/n + c(-1, 1) * zcrit * sqrt((p * (1 -
21-
p) + z2/4/n)/n))/(1 + z2/n)
22-
if (x == 1)
23-
cl[1] <- -log(conf.level)/n
24-
if (x == (n - 1))
25-
cl[2] <- 1 + log(conf.level)/n
26-
asymp.lcl <- x/n - qnorm(1/2+conf.level/2) * sqrt(((x/n) *
27-
(1 - x/n))/n)
28-
asymp.ucl <- x/n + qnorm(1/2+conf.level/2) * sqrt(((x/n) *
29-
(1 - x/n))/n)
30-
res <- rbind(c(ll, ul), cl, c(asymp.lcl, asymp.ucl))
31-
res <- cbind(rep(x/n, 3), res)
32-
switch(method, Wilson = res[2, ], exact = res[1, ], Wald = res[3,
33-
], all = res, res)
34-
}
35-
if ((length(x) != length(n)) & length(x) == 1)
36-
x <- rep(x, length(n))
37-
if ((length(x) != length(n)) & length(n) == 1)
38-
n <- rep(n, length(x))
39-
if ((length(x) > 1 | length(n) > 1) & method == "all") {
40-
method <- "Wilson"
41-
warning("method=all will not work with vectors...setting method to Wilson")
42-
}
43-
if (method == "all" & length(x) == 1 & length(n) == 1) {
44-
mat <- bc(x, n, conf.level, method)
45-
dimnames(mat) <- list(c("Exact", "Wilson", "Wald"),
46-
c("PointEst", "Lower", "Upper"))
47-
return(mat)
48-
}
49-
mat <- matrix(ncol = 3, nrow = length(x))
50-
for (i in 1:length(x)) mat[i, ] <- bc(x[i], n[i], conf.level = conf.level,
51-
method = method)
52-
dimnames(mat) <- list(rep("", dim(mat)[1]), c("PointEst",
53-
"Lower", "Upper"))
54-
mat
55-
}
1+
#' Intervalles de confiance pour une proportion
2+
#'
3+
#' Cette fonction permet de calculer plusieurs types d'intervalles de confiance
4+
#' pour une proportion.
5+
#'
6+
#'
7+
#' @param x Nombre de succès
8+
#' @param n Nombre d'essais
9+
#' @param conf.level Niveau de confiance recherché pour l'intervalle
10+
#' @param method Type d'intervalle de confiance à calculer : intervalle de
11+
#' "Wilson", intervalle "exact" de Clopper-Pearson, intervalle asymptotique de
12+
#' "Wald" ou tous les trois "all"
13+
#' @return \item{matrix}{Limites des intervalles de confiance demandés.}
14+
#' @author Frédéric Bertrand\cr \email{frederic.bertrand@@math.unistra.fr}\cr
15+
#' \url{http://www-irma.u-strasbg.fr/~fbertran/}\cr
16+
#' Maumy-Bertrand\cr \email{myriam.maumy@@math.unistra.fr}\cr
17+
#' \url{http://www-irma.u-strasbg.fr/~mmaumy/}
18+
#' @seealso \code{\link{binom.test}}, \code{\link{binom.ci}},
19+
#' \code{\link{poi.ci}}
20+
#' @references F. Bertrand, M. Maumy-Bertrand, Initiation à la Statistique avec
21+
#' R, Dunod, 3ème edition, 2018.
22+
#' @keywords univar
23+
#' @examples
24+
#'
25+
#' binom.ci(5,10,method="all")
26+
#'
27+
#' @export binom.ci
28+
binom.ci <- function (x, n, conf.level = 0.95, method = c("Wilson", "exact", "Wald",
29+
"all"))
30+
{
31+
method <- match.arg(method)
32+
bc <- function(x, n, conf.level, method) {
33+
nu1 <- 2 * (n - x + 1)
34+
nu2 <- 2 * x
35+
ll <- if (x > 0)
36+
x/(x + qf(1/2 + conf.level/2, nu1, nu2) * (n - x + 1))
37+
else 0
38+
nu1p <- nu2 + 2
39+
nu2p <- nu1 - 2
40+
pp <- if (x < n)
41+
qf(1/2 + conf.level/2, nu1p, nu2p)
42+
else 1
43+
ul <- ((x + 1) * pp)/(n - x + (x + 1) * pp)
44+
zcrit <- -qnorm((1-conf.level)/2)
45+
z2 <- zcrit * zcrit
46+
p <- x/n
47+
cl <- (p + z2/2/n + c(-1, 1) * zcrit * sqrt((p * (1 -
48+
p) + z2/4/n)/n))/(1 + z2/n)
49+
if (x == 1)
50+
cl[1] <- -log(conf.level)/n
51+
if (x == (n - 1))
52+
cl[2] <- 1 + log(conf.level)/n
53+
asymp.lcl <- x/n - qnorm(1/2+conf.level/2) * sqrt(((x/n) *
54+
(1 - x/n))/n)
55+
asymp.ucl <- x/n + qnorm(1/2+conf.level/2) * sqrt(((x/n) *
56+
(1 - x/n))/n)
57+
res <- rbind(c(ll, ul), cl, c(asymp.lcl, asymp.ucl))
58+
res <- cbind(rep(x/n, 3), res)
59+
switch(method, Wilson = res[2, ], exact = res[1, ], Wald = res[3,
60+
], all = res, res)
61+
}
62+
if ((length(x) != length(n)) & length(x) == 1)
63+
x <- rep(x, length(n))
64+
if ((length(x) != length(n)) & length(n) == 1)
65+
n <- rep(n, length(x))
66+
if ((length(x) > 1 | length(n) > 1) & method == "all") {
67+
method <- "Wilson"
68+
warning("method=all will not work with vectors...setting method to Wilson")
69+
}
70+
if (method == "all" & length(x) == 1 & length(n) == 1) {
71+
mat <- bc(x, n, conf.level, method)
72+
dimnames(mat) <- list(c("Exact", "Wilson", "Wald"),
73+
c("PointEst", "Lower", "Upper"))
74+
return(mat)
75+
}
76+
mat <- matrix(ncol = 3, nrow = length(x))
77+
for (i in 1:length(x)) mat[i, ] <- bc(x[i], n[i], conf.level = conf.level,
78+
method = method)
79+
dimnames(mat) <- list(rep("", dim(mat)[1]), c("PointEst",
80+
"Lower", "Upper"))
81+
mat
82+
}

R/cvar.R

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
cvar <- function(x){100*sd(x)/mean(x)}
2-
3-
4-
1+
#' Coefficient de variation
2+
#'
3+
#' Calcule coefficent de variation d'une série statistique
4+
#'
5+
#' Le coefficient de variation est égal à l'écart-type corrigé divisé par la
6+
#' moyenne. Il est exprimé en pourcents.
7+
#'
8+
#' @param x Un vecteur numérique
9+
#' @return \item{num}{Valeur du coefficient de variation exprimé en pourcents}
10+
#' @author Frédéric Bertrand\cr \email{frederic.bertrand@@math.unistra.fr}\cr
11+
#' \url{http://www-irma.u-strasbg.fr/~fbertran/}\cr
12+
#' Maumy-Bertrand\cr \email{myriam.maumy@@math.unistra.fr}\cr
13+
#' \url{http://www-irma.u-strasbg.fr/~mmaumy/}
14+
#' @seealso \code{\link{mean}}, \code{\link{sd}}
15+
#' @references F. Bertrand, M. Maumy-Bertrand, Initiation à la Statistique avec
16+
#' R, Dunod, 3ème edition, 2018.
17+
#' @keywords univar
18+
#' @examples
19+
#'
20+
#' data(Europe)
21+
#' cvar(Europe[,2])
22+
#'
23+
#' @export cvar
24+
cvar <- function(x){100*sd(x)/mean(x)}
25+
26+
27+

0 commit comments

Comments
 (0)