Articles

Bug in shiny::updateCheckboxGroupInput()

If you want unselected all checkboxes defined using  updateCheckboxGroupInput , the syntax should be: updateCheckboxGroupInput(session, inputId, selected = NULL) However, it does not work. You must indicate again the parameter choices explicitly Look at this code: rm(list = ls()) library(shiny) runApp(list(   ui = basicPage(     checkboxGroupInput('chkGrp',                         label="Choix",                         choices=list("A"="a", "B"="b", "C"="c", "D"="d", "E"="e")),     actionButton("all","All"),     actionButton("noneWithChoices","None With Choices"),     actionButton("noneWithoutChoices","None Without Choices"),     actionButton("partial","Partial"),     verbatimTextOutput("value")   ),   server = function(input, output, session) {   ...

Example of using bootstraps to estimate SE of a mean

Image
Just a little game to know better bootstraps. Note that when the number of observations is low, the estimator is biased. See here for a solution: Bondy, Warren; Zlot, William (1976). "The Standard Error of the Mean and the Difference Between Means for Finite Populations". The American Statistician. 30 (2): 96–97. finalerr <- NULL reptest <- c(10000, 50000, 100000) ltest <- c(10, 20, 30, 50, 100, 200, 300, 400, 500) for (rep in reptest) {   perror <- NULL   for (l in ltest) {          taille <- runif(n=l, min=160, max=180)          # The standard error of the series     # sd(taille)/sqrt(l)               m <- rep(NA, rep)     for (i in 1:rep) m[i] <- mean(taille[sample(x=1:l, size = l, replace = TRUE)])          # The standard deviation of the means obtained using bootstrap     # sd(m) ...

Install XML packages in MacOSX

In terminal, enter brew install libxml2 Then enter these 3 lines: export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig" export CPPFLAGS="-I/usr/local/opt/libxml2/include" export LDFLAGS="-L/usr/local/opt/libxml2/lib" You can put these lines in your .profile Then  R install.packages("XML")

Annoying message when install packages

If you get this annoying message when you update R packages in MacOSX: ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking. I have found a solution in internet by running these commands in terminal: sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.old xcode-select --install sudo rm -rf /Library/Developer/CommandLineTools.old But it does not work for me :(

Install rstudio 1.1.463 in Ubuntu 18.04 32 bits

# Load old libraries libgstreamer0.10 wget http://fr.archive.ubuntu.com/ubuntu/pool/universe/g/gstreamer0.10/libgstreamer0.10-0_0.10.36-1.5ubuntu1_i386.deb wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gst-plugins-base0.10/libgstreamer-plugins-base0.10-0_0.10.36-2_i386.deb # Install them sudo dpkg -i libgstreamer0.10-0_0.10.36-1.5ubuntu1_i386.deb sudo dpkg -i libgstreamer-plugins-base0.10-0_0.10.36-2_i386.deb # Hold them to not change them during upgrade sudo apt-mark hold libgstreamer-plugins-base0.10-0 sudo apt-mark hold libgstreamer0.10 # Load last version of rstudio wget https://download1.rstudio.org/rstudio-1.1.463-i386.deb # Install it sudo gdebi rstudio-1.1.463-i386.deb # Clean rm libgstreamer0.10-0_0.10.36-1.5ubuntu1_i386.deb libgstreamer-plugins-base0.10-0_0.10.36-2ubuntu0.1_i386.deb rstudio-1.1.463-i386.deb # Done !

Install rgdal on ubuntu from scratch or using package manager

Using package manager , in shell, enter sudo apt install libgdal-dev Using this command can install old versions of some libraries. Using source: Check the current version here: https://gdal.org/download.html#current-release # This method is broken: ./configure is not found wget https://github.com/OSGeo/gdal/releases/download/v3.7.1/gdal-3.7.1.tar.gz tar -xf gdal-3.7.1.tar.gz cd gdal-3.7.1 ./configure make cd .. rm gdal-3.6.3.tar.gz rm -rf gdal-3.6.3 In R, enter: install.packages("rgdal")

SE for all levels of a factor after a glmm

When you are doing a LM, GLM or GLMM with fixed effect with categorical variable, it is impossible to get the SE for all levels because always one level is fixed to 0. But sometimes, you need to know how this level is really known. Two solutions are presented for this problem. The first solution is to force the intercept to be 0 but it works only when there is only one categorical fixed factor. The second is to use a method know as quasi-variance: Firth, D., de Mezezes, R.X., 2004. Quasi-variances. Biometrika 91, 65-80. It is available in package qvcalc for lm() and glm() and in package HelpersMG for lmer(). Here is an example with lmer(): x <- rnorm(100) y <- rnorm(100) G <- as.factor(sample(c("A", "B", "C", "D"), 100, replace = TRUE)) H <- as.factor(sample(c("A", "B", "C", "D"), 100, replace = TRUE)) R <- as.factor(rep(1:25, 4)) G <- relevel(G, "A") H <- ...