|
| 1 | +```{r} |
| 2 | +#| eval: false |
| 3 | +# version stable CRAN |
| 4 | +install.packages("fitdistrplus") |
| 5 | +
|
| 6 | +# version dev github |
| 7 | +install.packages("remotes") |
| 8 | +remotes::install_github("lbbe-software/fitdistrplus") |
| 9 | +
|
| 10 | +``` |
| 11 | +```{r} |
| 12 | +library(fitdistrplus) |
| 13 | +``` |
| 14 | + |
| 15 | + |
| 16 | +# baytrends |
| 17 | +```{r} |
| 18 | +#| label: baytrends |
| 19 | +#| warning: true |
| 20 | +#| error: true |
| 21 | +# dans le fichier test-impute.R |
| 22 | +# https://github.com/cran/baytrends/blob/master/tests/testthat/test-impute.R |
| 23 | +library(baytrends, quietly = TRUE) |
| 24 | +x <- dataCensored[1:20,"tdp"] |
| 25 | +calc_impute <- impute(x,'norm') |
| 26 | +calc_impute <- impute(x,'lnorm') |
| 27 | +``` |
| 28 | + |
| 29 | + |
| 30 | +# BMT |
| 31 | +```{r} |
| 32 | +#| label: BMT |
| 33 | +#| warning: true |
| 34 | +#| error: true |
| 35 | +# ligne 108 du fichier d'aide de BMTfit |
| 36 | +# https://github.com/cran/BMT/blob/master/man/BMTfit.Rd |
| 37 | +library(BMT, quietly = TRUE) |
| 38 | +data("groundbeef") |
| 39 | +serving <- groundbeef$serving |
| 40 | +fit.mme <- BMTfit(serving, method="mme") |
| 41 | +``` |
| 42 | + |
| 43 | +# criticality |
| 44 | + |
| 45 | +```{r} |
| 46 | +#| label: criticality |
| 47 | +#| warning: true |
| 48 | +#| error: true |
| 49 | +# https://github.com/cran/criticality/blob/master/man/BN.Rd |
| 50 | +library(criticality, quietly = TRUE) |
| 51 | +ext.dir <- paste0(tempdir(), "/criticality/extdata") |
| 52 | +dir.create(ext.dir, recursive = TRUE, showWarnings = FALSE) |
| 53 | +extdata <- paste0(.libPaths()[1], "/criticality/extdata") |
| 54 | +file.copy(paste0(extdata, "/facility.csv"), ext.dir, recursive = TRUE) |
| 55 | +file.copy(paste0(extdata, "/mcnp-dataset.RData"), ext.dir, recursive = TRUE) |
| 56 | +bb <- BN( |
| 57 | + facility.data = "facility.csv", |
| 58 | + ext.dir = ext.dir |
| 59 | +) |
| 60 | +``` |
| 61 | + |
| 62 | +# phenesse |
| 63 | +```{r} |
| 64 | +#| label: phenesse1 |
| 65 | +#| warning: true |
| 66 | +#| error: true |
| 67 | +# dans le fichier test-weib_percentile.R |
| 68 | +# https://github.com/cran/phenesse/blob/master/tests/testthat/test-weib_percentile.R |
| 69 | +# pour reproduire l'erreur, augmenter le nombre d'itérations |
| 70 | +# très très gourmand en ressources, fait planter R, voire l'ordi !! |
| 71 | +# ATTENTION !! |
| 72 | +library(phenesse, quietly = TRUE) |
| 73 | +x <- rnorm(n = 10, mean = 150, sd = 10) |
| 74 | +weib_percentile(x, percentile = 0.5, iterations = 1) |
| 75 | +
|
| 76 | +# phenesse (local) create_predict_df(observations) |
| 77 | +# fitdistrplus::fitdist(observations, distr = "weibull", method = "mle") |
| 78 | +``` |
| 79 | + |
| 80 | +```{r} |
| 81 | +#| label: phenesse2 |
| 82 | +#| warning: true |
| 83 | +#| error: true |
| 84 | +# dans la vignette |
| 85 | +# ligne 54 https://github.com/cran/phenesse/blob/master/vignettes/phenesse_vignette.Rmd |
| 86 | +# pour reproduire l'erreur, changer le nombre d'itérations |
| 87 | +# très très gourmand en ressources, fait planter R, voire l'ordi !! |
| 88 | +# ATTENTION !! |
| 89 | +data(inat_examples) |
| 90 | +s_cybele <- subset(inat_examples, scientific_name == "Speyeria cybele") |
| 91 | +weib_percentile(observations = s_cybele$doy, percentile = 0.01, iterations = 1) |
| 92 | +``` |
| 93 | + |
| 94 | +# stratifyR |
| 95 | + |
| 96 | +```{r} |
| 97 | +#| label: stratifyR |
| 98 | +#| warning: true |
| 99 | +#| error: true |
| 100 | +# dans la vignette |
| 101 | +library(stratifyR, quietly = TRUE) |
| 102 | +Folate <- anaemia$Folate |
| 103 | +res <- strata.data(Folate, h = 2, n = 500) |
| 104 | +``` |
| 105 | + |
| 106 | + |
| 107 | +# traitstrap |
| 108 | +```{r} |
| 109 | +#| label: traitstrap1 |
| 110 | +#| warning: true |
| 111 | +#| error: true |
| 112 | +# trait_fit_distributions |
| 113 | +# https://github.com/cran/traitstrap/blob/main/man/trait_fit_distributions.Rd |
| 114 | +library(traitstrap, quietly = TRUE) |
| 115 | +library(dplyr, quietly = TRUE) |
| 116 | +data(community) |
| 117 | +data(trait) |
| 118 | +
|
| 119 | +filled_traits <- trait_fill( |
| 120 | + comm = community |> |
| 121 | + filter(PlotID %in% c("A", "B")), |
| 122 | + traits = trait, |
| 123 | + scale_hierarchy = c("Site", "PlotID"), |
| 124 | + taxon_col = "Taxon", value_col = "Value", |
| 125 | + trait_col = "Trait", abundance_col = "Cover" |
| 126 | +) |
| 127 | +
|
| 128 | +fitted_distributions <- trait_fit_distributions( |
| 129 | + filled_traits = filled_traits, |
| 130 | + distribution_type = "normal" |
| 131 | +) |
| 132 | +``` |
| 133 | + |
| 134 | + |
| 135 | +```{r} |
| 136 | +#| label: traitstrap2 |
| 137 | +#| warning: true |
| 138 | +#| error: true |
| 139 | +test_vector <- rbeta(n = 100, shape1 = .5, shape2 = .5) |
| 140 | +aa <- traitstrap:::get_dist_parms(data = test_vector, distribution_type = "beta") |
| 141 | +``` |
0 commit comments